本文整理匯總了PHP中app\Article::findBySlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::findBySlug方法的具體用法?PHP Article::findBySlug怎麽用?PHP Article::findBySlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Article
的用法示例。
在下文中一共展示了Article::findBySlug方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $slug
* @return Response
*/
public function show($slug)
{
$article = Article::findBySlug($slug);
if ($article->published == 0) {
abort(404);
}
return view('blog.articles.show', compact('article'));
}
示例2: articulo
public function articulo($slug)
{
$article = Article::findBySlug($slug);
$my_tags = $article->tags;
$article->category;
$article->images;
$article->comments;
return view('front.show')->with('article', $article)->with('my_tags', $my_tags);
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show($slug)
{
$article = Article::findBySlug($slug);
return view('home.articles.show', compact('article'));
}
示例4: _getArticleOrFail
/**
* Get the article from a slug, checks if it exists, if not redirect with a flash message
*
* @param string $slug
* @param boolean $published
*
* @return mixed
*/
protected function _getArticleOrFail($slug, $published = false)
{
if ($published) {
$article = Article::findBySlug($slug)->where('published_at', '<=', Carbon::now());
} else {
$article = Article::findBySlug($slug);
}
if (!$article) {
redirect(route('articles.index'))->with('error', 'This article does not exist or has not been published yet!');
}
return $article;
}
示例5: show
public function show($id)
{
$article = Article::findBySlug($id);
return view('sample.show', compact('article'));
}