/**
  * @param  $id
  * @param  bool               $withRoles
  * @throws GeneralException
  * @return mixed
  */
 public function findOrThrowException($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     throw new GeneralException('That user does not exist.');
 }
Пример #2
0
 /**
  * @param  $id
  * @param  bool               $withRoles
  * @throws GeneralException
  * @return mixed
  */
 public function findOrThrowException($id, $withRoles = false)
 {
     if ($withRoles) {
         $user = User::with('roles')->withTrashed()->find($id);
     } else {
         $user = User::withTrashed()->find($id);
     }
     if (!is_null($user)) {
         return $user;
     }
     throw new GeneralException(trans('exceptions.backend.access.users.not_found'));
 }