本文整理汇总了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'));
}