本文整理汇总了PHP中app\Page::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::findOrFail方法的具体用法?PHP Page::findOrFail怎么用?PHP Page::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Page
的用法示例。
在下文中一共展示了Page::findOrFail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param int $id
*
* @return Response
*/
public function update($id, Request $request)
{
$page = Page::findOrFail($id);
$page->update($request->all());
Session::flash('flash_message', 'Page updated!');
return redirect('page');
}
示例2: update
/**
* Update the page in storage.
*
* @param PageRequest $request
* @param int $id
* @return Response
*/
public function update($id, PageRequest $request)
{
$page = Page::findOrFail($id);
$page->update($request->all());
flash()->success('Your page has been updated');
return redirect()->action('PagesController@edit', $page->id);
}
示例3: destroy
public function destroy($id)
{
$page = Page::findOrFail($id);
$page->delete();
Session::flash('delete_page', 'page has been deleted');
return redirect('panel/pages');
}
示例4: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
// bind article
$router->model('article', 'App\\Article');
$router->bind('admin.article', function ($id) {
return \App\Article::findOrFail($id);
});
// bind category
$router->model('category', 'App\\Category');
$router->bind('admin.category', function ($id) {
return \App\Category::findOrFail($id);
});
// bind language
$router->model('language', 'App\\Language');
$router->bind('admin.language', function ($id) {
return \App\Language::findOrFail($id);
});
// bind language
$router->model('page', 'App\\Page');
$router->bind('admin.page', function ($id) {
return \App\Page::findOrFail($id);
});
// bind setting
$router->model('setting', 'App\\Setting');
$router->bind('admin.setting', function ($id) {
return \App\Setting::findOrFail($id);
});
// bind user
$router->model('user', 'App\\User');
$router->bind('admin.user', function ($id) {
return \App\User::findOrFail($id);
});
parent::boot($router);
}
示例5: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['title' => 'required']);
$item = Page::findOrFail($id);
$item->update($request->all());
Flash::success("Запись - {$id} обновлена");
return redirect(route('admin.pages.index'));
}
示例6: show
/**
* Display the specified resource.
*
* @param int $id
* @param Request $request
* @return Response
*/
public function show($id, Request $request)
{
$page = Page::findOrFail($id);
if ($request->ajax()) {
return response()->json($page);
}
return $page;
}
示例7: edit
public function edit(Request $request)
{
$page_menu_position = [Page::HEADER_MENU => trans('admin_common.Header Menu'), Page::FOOTER_MENU => trans('admin_common.Footer Menu')];
$id = 0;
if (isset($request->id)) {
$id = $request->id;
}
$modelData = new \stdClass();
if ($id > 0) {
try {
$modelData = Page::findOrFail($id);
} catch (ModelNotFoundException $e) {
session()->flash('message', trans('admin_common.Invalid Page'));
return redirect(url('admin/page'));
}
}
/**
* form is submitted check values and save if needed
*/
if ($request->isMethod('post')) {
/**
* validate data
*/
$rules = ['page_position' => 'required|integer|not_in:0', 'page_slug' => 'required|max:255|unique:page,page_slug', 'page_title' => 'required|max:255', 'page_content' => 'required', 'page_ord' => 'required|integer'];
if (isset($modelData->page_id)) {
$rules['page_slug'] = 'required|max:255|unique:page,page_slug,' . $modelData->page_id . ',page_id';
}
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
/**
* get data from form
*/
$data = $request->all();
if (isset($data['page_active'])) {
$data['page_active'] = 1;
} else {
$data['page_active'] = 0;
}
/**
* save or update
*/
if (!isset($modelData->page_id)) {
Page::create($data);
} else {
$modelData->update($data);
}
/**
* clear cache, set message, redirect to list
*/
Cache::flush();
session()->flash('message', trans('admin_common.Page saved'));
return redirect(url('admin/page'));
}
return view('admin.page.page_edit', ['modelData' => $modelData, 'page_menu_position' => $page_menu_position]);
}
示例8: 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);
$page->name = $request->name;
$page->content = $request->content;
$page->save();
return redirect()->action('PageController@index')->with('status', 'Page Updated!');
}
示例9: update
public function update(PagesRequest $request, $id)
{
$page = Page::findOrFail($id);
$page->title = $request->title;
$page->body = $request->body;
$page->save();
\Flash::success('Pagina aangepast');
return redirect('admin');
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id, PageRequest $request)
{
$page = Page::findOrFail($id);
$page->fill($request->all());
$page->modified_by = Auth::user()->id;
$page->save();
flash()->success('Page Updated');
return redirect('pages');
}
示例11: getFullUrlAttribute
public function getFullUrlAttribute()
{
if ($this->parent > 0) {
$parent = Page::findOrFail($this->parent);
return $parent->fullUrl . '/' . $this->url;
} else {
return $this->url;
}
}
示例12: updatePage
public function updatePage($pageId)
{
$page = Page::findOrFail($pageId);
$page->title = Request::get('title');
$page->body = Request::get('body');
$page->admin_user_id = Request::get('admin_user_id');
$page->update();
return Redirect::to('/admin/page/' . $pageId);
}
示例13: update
/**
* Update the page content.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(PageRequest $request, $id)
{
$page = Page::findOrFail($id);
$page->description = $request->get('description');
$page->content = $request->get('content');
$page->image = $request->get('image');
$page->save();
flash('Page sucessfully updated');
return redirect()->route('admin-pages.index');
}
示例14: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$page = Page::findOrFail($id);
$contentAreas = ContentArea::orderBy('display_order', 'Asc')->get();
$pagesAll = Page::all();
$articlesAll = Article::all();
$templatesAll = Template::all();
$contentAreasAll = ContentArea::all();
return view('site.show', compact('contentAreas', 'page', 'pagesAll', 'articlesAll', 'templatesAll', 'contentAreasAll'));
}
示例15: update
public function update(Requests\Pages\EditPageRequest $request, $id, StoreFile $storeFile, \App\Page $page)
{
if ($request->hasFile('image')) {
$image_path = $storeFile->move($request->file('image'), 'images/pages/', 16);
$modified_request = array_merge($request->all(), ['image' => $image_path]);
} else {
$modified_request = $request->except('image');
}
$page->findOrFail($id)->update($modified_request);
//Redirect
return redirect()->action('Panel\\PagesController@index');
}