45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use App\Classc\SearchScopeTrait;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
//
|
|
use SearchScopeTrait, Notifiable;
|
|
protected $hidden = [
|
|
'password', 'remember_token'
|
|
];
|
|
protected $fillable = [
|
|
'nickname', 'password', 'email', 'from_user_id', 'merchant_id', 'from_ip', 'mobile'
|
|
];
|
|
protected $guarded = [];
|
|
// public function setPasswordAttribute($password) {
|
|
// if($password)
|
|
// {
|
|
// $this->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);
|
|
}
|
|
}
|
|
}
|