attributes['password'] = bcrypt($password); // } // // } public function merchants() { return $this->belongsTo('App\Models\Merchant', 'merchant_id', 'id')->withDefault([ 'name' => '本站' ]); } public static function getOrCreate($data = [], $where) { $has_user = self::where($where)->first(); if (!empty($has_user)) { return $has_user; } else { return self::create($data); } } }