/** * @param $slug * @return mixed */ public function showPost($slug, Request $request) { $post = Post::with('tags')->whereSlug($slug)->firstOrFail(); $tag = $request->get('tag'); if ($tag) { $tag = Tag::whereTag($tag)->firstOrFail(); } return view($post->layout, compact('post', 'tag', 'slug')); }
/** * Return data for normal index page * * @return array */ protected function normalIndexData() { $posts = Post::with('tags')->where('published_at', '<=', Carbon::now())->where('is_draft', 0)->orderBy('published_at', 'desc')->simplePaginate(config('blog.posts_per_page')); return ['title' => config('blog.title'), 'subtitle' => config('blog.subtitle'), 'posts' => $posts, 'page_image' => config('blog.page_image'), 'meta_description' => config('blog.description'), 'reverse_direction' => false, 'tag' => null]; }