예제 #1
0
 /**
  * Show the user dashboard.
  *
  * @param int $id
  * @return \Illuminate\Http\Response
  */
 public function showUserEvents()
 {
     //Returns all events that the user is attending
     $rsvp = Event::join('rsvp', 'events.id', '=', 'rsvp.eventid')->join('users', 'users.id', '=', 'rsvp.userid')->select('events.*')->where('rsvp.userid', '=', Auth::user()->id)->whereNull('events.deleted_at')->distinct()->get();
     //Returns all events that the user previously attended
     $pastrsvp = Event::join('rsvp', 'events.id', '=', 'rsvp.eventid')->join('users', 'users.id', '=', 'rsvp.userid')->select('events.*')->where('rsvp.userid', '=', Auth::user()->id)->whereNotNull('events.deleted_at')->onlyTrashed()->distinct()->get();
     //Checks if the user is an admin
     $admin = Admin::join('users', 'users.id', '=', 'admins.userid')->select('admins.*')->where(['userid' => Auth::user()->id])->distinct()->get();
     //returns dash view with $rsvp array with query results from above
     return view('dash', ['rsvp' => $rsvp, 'admin' => $admin, 'pastrsvp' => $pastrsvp]);
 }