本文整理汇总了PHP中app\Event::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::join方法的具体用法?PHP Event::join怎么用?PHP Event::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Event
的用法示例。
在下文中一共展示了Event::join方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editForm
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]);
}
示例2: show
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]);
}
示例3: showUserEvents
/**
* 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]);
}