'array']; protected $fillable = ['username', 'password', 'nickname', 'avatar']; use SoftDeletes, HasDateTimeFormatter; public function __construct(array $attributes = []) { parent::__construct($attributes); $this->setTable(plugin()->webman->config('database.user_table')); } /** * 角色 * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany */ public function roles(){ return $this->belongsToMany(plugin()->webman->config('database.role_model'),plugin()->webman->config('database.role_user_model'), 'user_id', 'role_id'); } /** * 部门 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function department(){ return $this->belongsTo(plugin()->webman->config('database.department_model'), 'department_id'); } /** * 功能 * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough */ public function permission() { return $this->hasManyThrough(plugin()->webman->config('database.role_permission_model'), plugin()->webman->config('database.role_user_model'), 'user_id', 'role_id','id','role_id'); } /** * 密码哈希加密 * @param $value */ public function setPasswordAttribute($value){ $this->attributes['password'] = password_hash($value,PASSWORD_DEFAULT); } }