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


PHP Article::findBySlugOrFail方法代码示例

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


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

示例1: viewArticle

 public function viewArticle($slug)
 {
     $article = Article::findBySlugOrFail($slug);
     $article->category;
     $article->images;
     return view('vistas.article')->with('article', $article);
 }
开发者ID:EstevenJaviier,项目名称:Semillero-IN,代码行数:7,代码来源:HomeController.php

示例2: viewArticle

 public function viewArticle($slug)
 {
     $article = Article::findBySlugOrFail($slug);
     $article->category;
     $article->user;
     $article->tags;
     $article->images;
     return view('front.article')->with('article', $article);
 }
开发者ID:eloyespeche,项目名称:BlogLaravelFinal,代码行数:9,代码来源:FrontController.php

示例3: contentArticle

 public function contentArticle($slug)
 {
     $article = Article::findBySlugOrFail($slug);
     $article->category;
     $article->user;
     $article->tags;
     $article->images;
     return view('front.content', compact('article'));
 }
开发者ID:JhonatanC,项目名称:laravelcodfa,代码行数:9,代码来源:FrontController.php

示例4: 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

示例5: 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

示例6: index

 /**
  * Show the article.
  *
  * @param String $slug
  * @return Response
  */
 public function index(string $slug)
 {
     $article = Article::findBySlugOrFail($slug);
     Event::fire(new ArticleWasViewed($article));
     return view('application.article.index', compact('article'));
 }
开发者ID:thinhhung,项目名称:laravel-5-simple-cms,代码行数:12,代码来源:ArticleController.php


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