本文整理汇总了PHP中app\models\Page::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::findOrFail方法的具体用法?PHP Page::findOrFail怎么用?PHP Page::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Page
的用法示例。
在下文中一共展示了Page::findOrFail方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id, Request $request)
{
//$this->validate($request, ['name' => 'required']); // Uncomment and modify if you need to validate any input.
$page = Page::findOrFail($id);
$page->update($request->all());
return redirect('pages');
}
示例2: patchUpdate
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function patchUpdate($id, Request $request)
{
$this->validate($request, ['slug' => 'required|unique:pages,slug,' . $id]);
// Uncomment and modify if you need to validate any input.
$page = Page::findOrFail($id);
$page->update($request->all());
return redirect('/admin/pages');
}
示例3: pageDelete
public function pageDelete($id)
{
try {
$page = Page::findOrFail($id);
} catch (ModelNotFoundException $e) {
return response('Page not found.', 404);
}
$page->delete();
return redirect()->route('admin.pages.static');
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$page = Page::findOrFail($id);
$validator = \Validator::make($request->all(), ['title' => 'required|max:255', 'url' => 'required|alpha_dash|max:255' . ($page->url == $request->get("url") ? '' : '|unique:pages'), 'keywords' => 'max:255', 'description' => 'required|max:1000', 'content' => 'required|max:40000', 'active' => 'boolean']);
if (!$validator->fails()) {
$page->title = $request->get("title");
$page->url = $request->get("url");
$page->keywords = $request->get("keywords");
$page->description = $request->get("description");
$page->content = $request->get("content");
$page->active = $request->has("active");
$page->save();
} else {
$this->throwValidationException($request, $validator);
}
return redirect()->back();
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
return view('admin.pages.edit')->withData(Page::findOrFail($id));
}
示例6: assets
public function assets(Request $request, $id, $file)
{
$page = Page::findOrFail($id);
return $page->component->response($file);
}