我的收藏

This commit is contained in:
2025-11-26 17:35:38 +08:00
parent a924959365
commit 12812fa775
5 changed files with 68 additions and 8 deletions
+26 -2
View File
@@ -105,8 +105,6 @@ class PostCommentService
return $data;
}
/**
* 添加后置处理
*/
@@ -123,4 +121,30 @@ class PostCommentService
$post['comment'] = $post['comment']+1;
$post->save();
}
/**
* 添加后置处理
*/
public function serviceDelete(Request $request)
{
$param = $request->all();
if (empty($param['id'])) {
throw new \Exception("参数错误");
}
$where = [];
$where['id'] = $param['id'];
$comment = PostComment::where($where)->first();
$post = Post::where(['id' => $comment['post_id']])->first();
$post['comment'] = $post['comment']-1;
$post->save();
$count = $comment->delete();
return $count;
}
}