From f3d6023ef858e381feff59eda843ab7aad7a33d4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 25 Jul 2021 03:19:48 -0600 Subject: [PATCH] Update LikeController, improve query perf --- app/Http/Controllers/LikeController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Controllers/LikeController.php b/app/Http/Controllers/LikeController.php index 9597465ba..725e2eb2a 100644 --- a/app/Http/Controllers/LikeController.php +++ b/app/Http/Controllers/LikeController.php @@ -29,8 +29,7 @@ class LikeController extends Controller $profile = $user->profile; $status = Status::findOrFail($request->input('item')); - - if ($status->likes()->whereProfileId($profile->id)->count() !== 0) { + if (Like::whereStatusId($status->id)->whereProfileId($profile->id)->exists()) { $like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail(); UnlikePipeline::dispatch($like); } else {