From 809423914f708979cd91edc307276d1bea3ed1ba Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 21 Sep 2018 23:31:21 -0600 Subject: [PATCH 1/3] Update discover controller --- app/Http/Controllers/DiscoverController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 2e3f57808..c01770dc9 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -19,8 +19,12 @@ class DiscoverController extends Controller $this->middleware('auth'); } - public function home() + public function home(Request $request) { + $this->validate($request, [ + 'page' => 'nullable|integer|max:50' + ]); + $pid = Auth::user()->profile->id; $following = Cache::remember('feature:discover:following:'.$pid, 15, function() use($pid) { @@ -52,6 +56,7 @@ class DiscoverController extends Controller ->whereHas('profile', function($q) { $q->where('is_private', false); }) + ->whereIsNsfw(false) ->whereVisibility('public') ->where('profile_id', '!=', $pid) ->whereNotIn('profile_id', $following) From 5ab2fe10901f83b3f0383b6e361f77bc7c7bc627 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 21 Sep 2018 23:44:33 -0600 Subject: [PATCH 2/3] Update discover controller --- app/Http/Controllers/DiscoverController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index c01770dc9..5c910415e 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -60,6 +60,7 @@ class DiscoverController extends Controller ->whereVisibility('public') ->where('profile_id', '!=', $pid) ->whereNotIn('profile_id', $following) + ->withCount(['comments', 'likes']) ->orderBy('created_at', 'desc') ->simplePaginate(21); From 02898ce679f2f8da83e4513b6ace98e50c19d348 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 21 Sep 2018 23:46:45 -0600 Subject: [PATCH 3/3] Update Discover feature --- resources/views/discover/home.blade.php | 74 ++++++++++++++++++------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/resources/views/discover/home.blade.php b/resources/views/discover/home.blade.php index eb1137cf0..ca1e3ddb7 100644 --- a/resources/views/discover/home.blade.php +++ b/resources/views/discover/home.blade.php @@ -36,26 +36,28 @@

Explore

-
- @foreach($posts as $status) -
- -
-
-
-
- - {{$status->likes_count}} - - - {{$status->comments_count}} - -
+
- @endforeach @if($posts->count() == 0)
@@ -63,12 +65,46 @@
@endif +
+
+
+ {{$posts->links()}} +
+
@endsection @push('meta') - + +@endpush + +@push('scripts') + + @endpush