public function getFromUserId($user_id) { // checks if the user exists try { User::findOrFail($user_id); } catch (ModelNotFoundException $e) { throw new UserNotFoundException(); } // gets the profile $profile = $this->model->where('user_id', '=', $user_id)->get(); // check if the profile exists if ($profile->isEmpty()) { throw new ProfileNotFoundException(); } return $profile->first(); }
/** * Remove a group to the user * * @param $id group id * @throws \LaravelAcl\Authentication\Exceptions\UserNotFoundException */ public function removeGroup($user_id, $group_id) { try { $group = Group::findOrFail($group_id); $user = User::findOrFail($user_id); $user->removeGroup($group); } catch (ModelNotFoundException $e) { throw new NotFoundException(); } }