登录
This commit is contained in:
+10
-68
@@ -4,21 +4,6 @@ namespace app\common\model;
|
||||
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* users 用户表
|
||||
* @property integer $id 用户ID(主键)
|
||||
* @property string $sn 编号
|
||||
* @property string $name 姓名
|
||||
* @property string $avatar 头像
|
||||
* @property string $password 密码
|
||||
* @property string $phone 手机
|
||||
* @property string $email 邮箱
|
||||
* @property integer $status 状态
|
||||
* @property string $system_code 系统码
|
||||
* @property string $report_to 上级用户ID
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
/**
|
||||
@@ -48,60 +33,17 @@ class User extends Model
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
|
||||
protected $dateFormat = 'U';
|
||||
|
||||
protected $fillable = [
|
||||
'sn',
|
||||
'name',
|
||||
'avatar',
|
||||
'sex',
|
||||
'password',
|
||||
'phone',
|
||||
'email',
|
||||
'status',
|
||||
'corp_id',
|
||||
'user_type',
|
||||
'union_id',
|
||||
'user_id',
|
||||
'open_id',
|
||||
'tenant_key',
|
||||
'country_id',
|
||||
'position',
|
||||
'socialize',
|
||||
'socialize_pic',
|
||||
'report_to',
|
||||
];
|
||||
|
||||
// 用户所有角色
|
||||
public function roles()
|
||||
{
|
||||
return $this->belongsToMany(Role::class, 'user_roles', 'user_id', 'role_id');
|
||||
}
|
||||
|
||||
// 用户直接拥有的资源(用于特殊补权)
|
||||
public function resources()
|
||||
{
|
||||
return $this->belongsToMany(Resource::class, 'user_resources', 'user_id', 'resource_id')->orderBy('sort', 'asc');
|
||||
}
|
||||
/**
|
||||
* 允许自动填充模型字段
|
||||
*/
|
||||
protected $fillable = ['id', 'union_id', 'app_id', 'name'];
|
||||
|
||||
// 用户可访问的系统
|
||||
public function systems()
|
||||
{
|
||||
return $this->belongsToMany(Systems::class, 'user_systems', 'user_id', 'system_id');
|
||||
}
|
||||
|
||||
// 账号查询的作用域
|
||||
public function scopeByAccount($query, $account)
|
||||
{
|
||||
return $query->where('sn', $account)
|
||||
->orWhere('phone', $account)
|
||||
->orWhere('email', $account);
|
||||
}
|
||||
|
||||
|
||||
public function reportToInfo()
|
||||
{
|
||||
return $this->hasOne(User::class, 'id', 'report_to');
|
||||
}
|
||||
/**
|
||||
* 不允许自动填充模型字段
|
||||
*/
|
||||
protected $guarded = [];
|
||||
}
|
||||
Reference in New Issue
Block a user