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('construct::' . $post->layout, compact('post', 'tag')); }
/** * 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('site.posts_per_page')); return ['title' => config('site.title'), 'subtitle' => config('site.subtitle'), 'posts' => $posts, 'page_image' => config('site.page_image'), 'meta_description' => config('site.description'), 'reverse_direction' => false, 'tag' => null]; }