本文整理匯總了PHP中app\Event::findBySlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::findBySlug方法的具體用法?PHP Event::findBySlug怎麽用?PHP Event::findBySlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Event
的用法示例。
在下文中一共展示了Event::findBySlug方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($slug)
{
$event = Event::findBySlug($slug);
$chair_id = (int) \Request::get('chair_id');
if (\Auth::id() === $chair_id) {
$result = $event->update(array('chair_id' => $chair_id));
}
if ($result) {
return response('Event chair updated!');
} else {
abort(409, 'There was an issue updating the registration.');
}
}
示例2: registrations
public function registrations($slug)
{
$event = Event::findBySlug($slug);
// Check if exists
if (!$event) {
abort(404);
}
$registrations = $event->allRegistrations();
return view('pages.admin.events.registrations', compact('event', 'registrations'));
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($slug, $id)
{
$event = Event::findBySlug($slug);
if ($id == 'self') {
if (\Auth::check()) {
EventRegistration::where('user_id', '=', \Auth::id())->where('event_id', '=', $event->id)->delete();
}
} else {
EventRegistration::destroy($id);
}
}