/** * Display the specified article. * * @param int $slug * @return \Illuminate\Http\Response */ public function show($slug) { /* * -------------------------------------------------------------------------- * Populate single article view * -------------------------------------------------------------------------- * Find published article by slug, build breadcrumb stack, retrieve article * author, article tags, related and popular article. */ $article = $this->article->whereSlug($slug)->firstOrFail(); if ($article->status == 'pending') { return view('article.pending', compact('article')); } if ($article->status == 'published') { $category = $article->subcategory->category->category; $subcategory = $article->subcategory->subcategory; $comments = $article->comments; $breadcrumb = ['Archive' => route('article.archive'), $category => route('article.category', [str_slug($category)]), $subcategory => route('article.subcategory', [str_slug($category), str_slug($subcategory)])]; $previous_article = $this->article->navigateArticle($article->id, 'prev'); $next_article = $this->article->navigateArticle($article->id, 'next'); $prev_ref = $previous_article != null ? route('article.show', [$previous_article->slug]) : '#'; $next_ref = $next_article != null ? route('article.show', [$next_article->slug]) : '#'; $tags = $article->tags()->get(); $related = $this->article->related($article->id); $popular = $this->article->mostPopular(5); $contributor = new Contributor(); $author = $contributor->profile($article->contributor->username); return view('article.article', compact('breadcrumb', 'prev_ref', 'next_ref', 'article', 'author', 'comments', 'tags', 'related', 'popular')); } else { abort(404); } }