/** * Assign Role to a User * * @param String $role */ public function assignRole($role) { if (is_string($role)) { return $this->roles()->attach(Role::whereTitle($role)->firstOrFail()); } return $this->roles()->save($role); }