Example #1
0
 /**
  * @param int|string $roleId
  *
  * @return bool
  */
 public function addRole($roleId)
 {
     //  This will fail if $roleId is bogus
     $this->removeRole($_role = $this->_getRole($roleId));
     return 1 == UserRole::insert(['role_id' => $_role->id, 'user_id' => $this->id]);
 }
 /**
  * Returns all assigned roles for a user
  *
  * @param int $userId
  *
  * @return Collection
  */
 protected static function findUserRoles($userId)
 {
     return UserRole::join('role_t', 'id', '=', 'role_id')->where('user_id', '=', $userId)->orderBy('role_t.role_name_text')->get(['role_t.*']);
 }