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


PHP Page::findBySlugOrFail方法代码示例

本文整理汇总了PHP中app\Page::findBySlugOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::findBySlugOrFail方法的具体用法?PHP Page::findBySlugOrFail怎么用?PHP Page::findBySlugOrFail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Page的用法示例。


在下文中一共展示了Page::findBySlugOrFail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @return void
  */
 public function boot()
 {
     parent::boot();
     Route::model('article', Article::class);
     Route::bind('article_slug', function ($slug) {
         return Article::findBySlugOrFail($slug);
     });
     Route::model('category', Category::class);
     Route::bind('category_slug', function ($slug) {
         return Category::findBySlugOrFail($slug);
     });
     Route::model('language', Language::class);
     Route::model('page', Page::class);
     Route::bind('page_slug', function ($slug) {
         return Page::findBySlugOrFail($slug);
     });
     Route::model('setting', Setting::class);
     Route::model('user', User::class);
 }
开发者ID:boynoiz,项目名称:laravel-5-simple-cms,代码行数:24,代码来源:RouteServiceProvider.php

示例2: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     $router->model('article', 'App\\Article');
     $router->bind('article_slug', function ($slug) {
         return Article::findBySlugOrFail($slug);
     });
     $router->model('category', 'App\\Category');
     $router->bind('category_slug', function ($slug) {
         return Category::findBySlugOrFail($slug);
     });
     $router->model('language', 'App\\Language');
     $router->model('page', 'App\\Page');
     $router->bind('page_slug', function ($slug) {
         return Page::findBySlugOrFail($slug);
     });
     $router->model('setting', 'App\\Setting');
     $router->model('user', 'App\\User');
 }
开发者ID:vassix,项目名称:laravel-5-simple-cms,代码行数:25,代码来源:RouteServiceProvider.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  * @param  string $slug
  * @return Response
  */
 public function destroy($slug)
 {
     // Delete
     $page = Page::findBySlugOrFail($slug, false);
     $status = $page->delete();
     // Flash message
     if ($status) {
         Flash::success('Page Deleted', "The page '" . $page->title . "' was successfully deleted.");
     } else {
         Flash::error('Error', "Something went wrong while trying to delete the page '" . $page->title . "'.");
     }
     // Redirect
     return redirect(route('page.index'));
 }
开发者ID:backstagetechnicalservices,项目名称:website,代码行数:19,代码来源:PagesController.php


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