attributes['password'] = app('hash')->needsRehash($password) ? Hash::make($password) : $password; } } public function getAvatarUrl() { return "https://www.gravatar.com/avatar/" . md5($this->email) . "?d=mm"; } public function getRoleNames(): Collection { return $this->roles->pluck('name'); } //public function roles() //{ // return $this->belongsToMany(\App\Role::class, 'link_accounts_roles', 'account_id', 'role_id'); //} public function is($roleName) { foreach ($this->roles()->get() as $role) { if ($role->name == $roleName) { return true; } } return false; } // public function assignRole($role) // { // return $this->roles()->attach($role); // } // public function revokeRole($role) // { // return $this->roles()->detach($role); // } // public function hasRole($name) // { // foreach ($this->roles as $role) // { // if ($role->name === $name) // { // return true; // } // return false; // } // return false; // } }