소스 검색

Update LikeController, improve query perf

Daniel Supernault 4 년 전
부모
커밋
f3d6023ef8
1개의 변경된 파일1개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 2
      app/Http/Controllers/LikeController.php

+ 1 - 2
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 {