Browse Source

Update DiscoverController

Daniel Supernault 6 năm trước cách đây
mục cha
commit
a616bd66f6
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      app/Http/Controllers/DiscoverController.php

+ 5 - 1
app/Http/Controllers/DiscoverController.php

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