浏览代码

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 {