本文整理汇总了PHP中app\models\Event::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::findOrFail方法的具体用法?PHP Event::findOrFail怎么用?PHP Event::findOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Event
的用法示例。
在下文中一共展示了Event::findOrFail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete($id)
{
$event = Event::findOrFail($id);
$event->delete();
flash('Ви успішно видалили подію!');
return back();
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(EventRequest $request, $id)
{
$event = Event::findOrFail($id);
$input = $request->input();
$validator = $event->getValidator($input);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors();
}
$event->event_name = $input['event_name'];
$event->event_start_date = Carbon::createFromFormat('d/m/Y h:i A', $input['event_start_date']);
$event->event_end_date = Carbon::createFromFormat('d/m/Y h:i A', $input['event_end_date']);
$event->save();
return redirect()->route('event.show', [$event->slug])->with('message', 'Event Updated');
}
示例3: getEvent
/**
* @param $id
* @return mixed
*/
public function getEvent($id)
{
return Event::findOrFail($id);
}
示例4: getDetails
public function getDetails(string $id_slug)
{
list($id, $name_slug) = unslug($id_slug);
$event = Event::findOrFail($id);
return view('event.details', compact('id', 'name_slug', 'event'));
}
示例5: show
/**
* Show a given event.
*
* @param Request $request
* @param int $id
* @return \Illuminate\View\View
*/
public function show(Request $request, $id)
{
$event = Event::findOrFail($id);
return view('events.show', compact('event'));
}
示例6: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$event = Event::findOrFail($id);
$event->delete();
Flash::success('The event has been successfully deleted.');
return redirect('admin/events');
}
示例7: show
public function show($id)
{
$event = Event::findOrFail($id);
$images = DB::table('files')->join('event_files', 'files.id', '=', 'event_files.file_id')->where('event_files.event_id', $event->id)->get();
return view('events.admin.detail', ['event' => $event, 'images' => $images]);
}