當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。