Beispiel #1
0
 /**
  * Display linked records of the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     // get all -- USERS -- with this specific role id
     $role = Role::find($id);
     $heading = 'User Management - Show ' . ucfirst($role->name) . 's';
     return view('admin.users', ['users' => $role->users()->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
 }
 /**
  * Display linked records of the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     // get all -- USERS -- with this specific instrument id
     $instrument = Instrument::find($id);
     if ($instrument) {
         $heading = 'User Management - Users playing ' . ucfirst($instrument->name);
         return view('admin.users', ['users' => $instrument->users()->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
     }
     $message = 'Error! Instrument with ID "' . $id . '" not found';
     return \Redirect::route($this->view_idx)->with(['status' => $message]);
 }
Beispiel #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     // show only active users
     // TODO: this currently produces duplicates...
     if ($request->has('active')) {
         $user1 = Role::find(4)->users()->get();
         $users = Role::find(5)->users()->get();
         foreach ($user1 as $value) {
             $users->prepend($value);
         }
         $heading = 'Show Active Users';
         return view($this->view_all, ['users' => $users, 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
     }
     // get all users in the requested order (default by id)
     $users = User::orderBy(isset($request->orderby) ? $request->orderby : 'id', isset($request->order) ? $request->order : 'asc');
     $heading = 'User Management';
     // check if user selected a filter
     if ($request->has('filterby') && $request->has('filtervalue') && $request->filtervalue != 'all') {
         if ($request->filterby == 'role') {
             // get all -- USERS -- with this specific role id
             $role = Role::find($request->filtervalue);
             $users = $role->users();
             $heading = 'User Management - Show ' . ucfirst($role->name) . 's';
         } else {
             if ($request->filterby == 'instrument') {
                 // get all -- USERS -- with this specific instrument id
                 $instrument = Instrument::find($request->filtervalue);
                 $users = $instrument->users();
                 $heading = 'User Management - Show users playing ' . ucfirst($instrument->name);
             } else {
                 $users = $users->where($request->filterby, $request->filtervalue);
             }
         }
     }
     return view($this->view_all, ['users' => $users->get(), 'heading' => $heading, 'roles' => Role::get(), 'instruments' => Instrument::get()]);
 }