本文整理匯總了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]);
}