'integer', 'status' => 'integer', 'created_by' => 'integer', 'updated_by' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'backend_setting' => 'array']; /** * 通过中间表关联角色 * @return \Hyperf\Database\Model\Relations\BelongsToMany */ public function roles() : \Hyperf\Database\Model\Relations\BelongsToMany { return $this->belongsToMany(SystemRole::class, 'system_user_role', 'user_id', 'role_id'); } /** * 通过中间表关联岗位 * @return \Hyperf\Database\Model\Relations\BelongsToMany */ public function posts() : \Hyperf\Database\Model\Relations\BelongsToMany { return $this->belongsToMany(SystemPost::class, 'system_user_post', 'user_id', 'post_id'); } /** * 通过中间表关联部门 * @return \Hyperf\Database\Model\Relations\BelongsToMany */ public function depts() : \Hyperf\Database\Model\Relations\BelongsToMany { return $this->belongsToMany(SystemDept::class, 'system_user_dept', 'user_id', 'dept_id'); } /** * 密码加密 * @param $value * @return void */ public function setPasswordAttribute($value) : void { $this->attributes['password'] = password_hash($value, PASSWORD_DEFAULT); } /** * 验证密码 * @param $password * @param $hash * @return bool */ public static function passwordVerify($password, $hash) : bool { return password_verify($password, $hash); } }