public function getSubredditMetaData($subreddit) { $sub = Subreddit::whereName($subreddit)->firstOrFail(); $data = ["subscriber_count" => count($sub->users), "post_count" => count($sub->posts), "description" => $sub->description]; return response()->json($data); }
public function showPost($subreddit, $permalink, $slug) { $sub = Subreddit::whereName($subreddit)->firstOrFail(); $post = $sub->posts()->wherePermalink($permalink)->whereSlug($slug)->firstOrFail(); return view('subreddit.showPost', compact('post')); }