attributes['password'] = bcrypt($password); } } public function role() { return $this->belongsTo(Role::class, 'role_id', 'id')->withDefault([ 'name' => 'Удалено' ]); } public function hasPermission(string $type, string $permission) : bool { return $this->role->hasPermission($type, $permission); } public function isAdmin() { return $this->role_id === 1; } // public function isModerator() // { // return $this->roles()->first()->pivot->role_id === 4; // } // // public function isContentManager() // { // return $this->roles()->first()->pivot->role_id === 3; // } }