public function editForm()
 {
     $eventNames = \App\Event::get()->pluck('name', 'id')->toArray();
     $mediaNames = \App\Media::get()->pluck('name', 'id')->toArray();
     $eventIDs = \App\Event::get()->pluck('id')->toArray();
     $mediaIDs = \App\Media::get()->pluck('id')->toArray();
     $mediaToEvents = array();
     $eventToMedia = array();
     foreach ($eventIDs as $eventID) {
         $eventToMedia[$eventID] = \App\Media::join('event_media', 'media.id', '=', 'event_media.mediaID')->where('event_media.eventID', $eventID)->get()->pluck('name', 'id')->toArray();
     }
     foreach ($mediaIDs as $mediaID) {
         $mediaToEvents[$mediaID] = \App\Event::join('event_media', 'events.id', '=', 'event_media.eventID')->where('event_media.mediaID', $mediaID)->get()->pluck('name', 'id')->toArray();
     }
     return view('forms/editRelationships')->with(['eventNames' => $eventNames, 'mediaNames' => $mediaNames, 'eventToMedia' => $eventToMedia, 'mediaToEvents' => $mediaToEvents]);
 }
Example #2
0
 public function show($id)
 {
     $media = \App\Media::where('id', $id)->get()->toArray();
     if (empty($media)) {
         App:
         abort(404);
     }
     $media = $media[0];
     $events = \App\Event::join('event_media', 'events.id', '=', 'event_media.eventID')->where('event_media.mediaID', $id)->get()->toArray();
     return view('show/media')->with(['media' => $media, 'events' => $events]);
 }
Example #3
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]);
 }