当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::findOrFail方法代码示例

本文整理汇总了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');
 }
开发者ID:AleksandrKovalev,项目名称:laravel_blog,代码行数:14,代码来源:PageController.php

示例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);
 }
开发者ID:vowsdesrat,项目名称:laravel,代码行数:14,代码来源:PagesController.php

示例3: destroy

 public function destroy($id)
 {
     $page = Page::findOrFail($id);
     $page->delete();
     Session::flash('delete_page', 'page has been deleted');
     return redirect('panel/pages');
 }
开发者ID:AliBedaer,项目名称:watania,代码行数:7,代码来源:PagesController.php

示例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);
 }
开发者ID:abada,项目名称:laravel-5-simple-cms,代码行数:40,代码来源:RouteServiceProvider.php

示例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'));
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:15,代码来源:PagesController.php

示例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;
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:15,代码来源:PagesController.php

示例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]);
 }
开发者ID:gdinko,项目名称:dclassifieds.laravel,代码行数:57,代码来源:PageController.php

示例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!');
 }
开发者ID:virtualone,项目名称:laravel5.1,代码行数:16,代码来源:PageController.php

示例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');
 }
开发者ID:svuvis,项目名称:oshusite,代码行数:9,代码来源:PagesController.php

示例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');
 }
开发者ID:chrismoulins,项目名称:Laravel,代码行数:15,代码来源:PageController.php

示例11: getFullUrlAttribute

 public function getFullUrlAttribute()
 {
     if ($this->parent > 0) {
         $parent = Page::findOrFail($this->parent);
         return $parent->fullUrl . '/' . $this->url;
     } else {
         return $this->url;
     }
 }
开发者ID:nickdekruijk,项目名称:larapages,代码行数:9,代码来源:Page.php

示例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);
 }
开发者ID:sanjibnarzary,项目名称:Admission,代码行数:9,代码来源:PageController.php

示例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');
 }
开发者ID:victorboissiere,项目名称:Synergie,代码行数:17,代码来源:PagesController.php

示例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'));
 }
开发者ID:chrismoulins,项目名称:Laravel,代码行数:16,代码来源:SiteController.php

示例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');
 }
开发者ID:omar3f,项目名称:new-watania,代码行数:12,代码来源:PagesController.php


注:本文中的app\Page::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。