帖子详情

This commit is contained in:
2025-11-27 18:41:57 +08:00
parent 8630b3c984
commit bf18a31d5f
4 changed files with 50 additions and 8 deletions
+6 -3
View File
@@ -126,9 +126,12 @@ class PostLikeService
$where['user_id'] = $param['user_id'];
$count = PostLike::where($where)->delete();
$post = Post::where(['id' => $param['post_id']])->first();
$post['like'] = $post['like']-1;
$post->save();
if ($count) {
$post = Post::where(['id' => $param['post_id']])->first();
$post['like'] = $post['like']-1;
$post['like'] = $post['like']<0?0:$post['like'];
$post->save();
}
return $count;
}