Update DiscoverController

This commit is contained in:
Daniel Supernault 2018-11-18 21:26:52 -07:00
parent 4a7a56f2cb
commit a616bd66f6
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -36,13 +36,17 @@ class DiscoverController extends Controller
->firstOrFail(); ->firstOrFail();
$posts = $tag->posts() $posts = $tag->posts()
->whereHas('media')
->withCount(['likes', 'comments']) ->withCount(['likes', 'comments'])
->whereIsNsfw(false) ->whereIsNsfw(false)
->whereVisibility('public') ->whereVisibility('public')
->has('media')
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->simplePaginate(12); ->simplePaginate(12);
if($posts->count() == 0) {
abort(404);
}
return view('discover.tags.show', compact('tag', 'posts')); return view('discover.tags.show', compact('tag', 'posts'));
} }
} }