本文整理汇总了PHP中Service::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::findOrFail方法的具体用法?PHP Service::findOrFail怎么用?PHP Service::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::findOrFail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified resource from storage.
* DELETE /services/{id}
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Service::findOrFail($id)->delete();
Flash::message('Service Deleted!');
return Redirect::route('services')->with('Flash_message', 'Service Deleted');
}
示例2: updateService
/**
* Update the specified service in storage.
*
* @param int $id
* @return Response
*/
public function updateService($id)
{
$service = Service::findOrFail($id);
$detail = Input::only('highlights', 'summary');
$condition = Input::only('special_condition', 'condition1', 'condition2');
$data = Input::except('highlights', 'summary', 'special_condition', 'condition1', 'condition2');
$validator = Validator::make($data, Service::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
ServiceDetail::where('id', (int) $data['detail_id'])->update($detail);
ServiceCondition::where('id', (int) $data['condition_id'])->update($condition);
$service->update($data);
return Redirect::route('admin.services.index');
}
示例3: showService
/**
* Display the specified service.
*
* @param int $id
* @return Response
*/
public function showService($id)
{
$service = Service::findOrFail($id);
return View::make('site.services.show', compact('service'));
}
示例4: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
return View::make('services.update')->with('service', Service::findOrFail($id))->with('title', 'Edit Service');
}