Explorar o código

Update LikeService, skip self likes

Daniel Supernault %!s(int64=4) %!d(string=hai) anos
pai
achega
3741c76da3
Modificáronse 1 ficheiros con 9 adicións e 1 borrados
  1. 9 1
      app/Services/LikeService.php

+ 9 - 1
app/Services/LikeService.php

@@ -62,8 +62,16 @@ class LikeService {
 		if(!$status->likes_count) {
 			return $empty;
 		}
+		$user = request()->user();
 
-		$like = Like::whereStatusId($status->id)->first();
+		if($user) {
+			$like = Like::whereStatusId($status->id)
+			->where('profile_id', '!=', $user->profile_id)
+			->first();
+		} else {
+			$like = Like::whereStatusId($status->id)
+			->first();
+		}
 
 		if(!$like) {
 			return $empty;