/** * Display the specified resource. * * @param string $post_slug * @return \Illuminate\Http\Response */ public function show($post_slug) { try { $post = Post::showing()->whereSlug($post_slug)->firstOrFail(); } catch (\Exception $e) { abort(404); } $post->viewed(); return view('flashtag::posts.show', compact('post')); }
/** * Display the search result page. * * @param \Illuminate\Http\Request $request * @return \Illuminate\View\View */ public function search(Request $request) { $query = $request->get('q', false); $posts = $query ? Post::showing()->search($query)->get() : collect([]); return view('flashtag::search', compact('posts', 'query')); }