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')); }
public function showPost($slug, Request $request, ShortenLink $shortenLink) { $post = Post::with('tags')->whereSlug($slug)->firstOrFail(); $tag = $request->get('tag'); $link = $shortenLink->shortenUrl($request->url()); $shortLink = $link->getShortUrl(); if ($tag) { $tag = Tag::whereTag($tag)->firstOrFail(); } return view($post->layout, compact('post', 'tag', 'slug', 'shortLink')); }