本文整理汇总了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);
}
示例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);
}
示例3: contentArticle
public function contentArticle($slug)
{
$article = Article::findBySlugOrFail($slug);
$article->category;
$article->user;
$article->tags;
$article->images;
return view('front.content', compact('article'));
}
示例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);
}
示例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');
}
示例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'));
}