From 8360aa4827e914b9136e74b08dce6ca0c838f13e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Jan 2020 21:50:05 -0700 Subject: [PATCH] Update StoryController, fix postgres bug --- app/Http/Controllers/StoryController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/StoryController.php b/app/Http/Controllers/StoryController.php index 1884bc945..c3443dd68 100644 --- a/app/Http/Controllers/StoryController.php +++ b/app/Http/Controllers/StoryController.php @@ -104,11 +104,12 @@ class StoryController extends Controller $profile = $request->user()->profile; $following = $profile->following->pluck('id')->toArray(); + $groupBy = config('database.default') == 'pgsql' ? 'id' : 'profile_id'; $stories = Story::with('profile') ->whereIn('profile_id', $following) ->where('expires_at', '>', now()) - ->groupBy('profile_id') + ->groupBy($groupBy) ->orderByDesc('expires_at') ->take(9) ->get()