Exemple #1
0
 /**
  * Return everything related to the Role
  * with eager loading
  *
  * @param null $role_id
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getCompleteRole($role_id = null)
 {
     $roles = RoleModel::with('permissions', 'users', 'affiliations');
     if (!is_null($role_id)) {
         $roles = $roles->where('id', $role_id)->first();
         if (!$roles) {
             abort(404);
         }
         return $roles;
     }
     return $roles->get();
 }
Exemple #2
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function getDetail($id)
 {
     $role = Role::with('users', 'permissions', 'affiliations')->where(is_numeric($id) ? 'id' : 'title', $id)->first();
     return response()->json($role);
 }