wzq před 5 roky
rodič
revize
76473a1e04
1 změnil soubory, kde provedl 7 přidání a 7 odebrání
  1. 7 7
      app/Repositories/PostRepositories.php

+ 7 - 7
app/Repositories/PostRepositories.php

@@ -299,19 +299,19 @@ class PostRepositories
 
         DB::beginTransaction();
         try{
-            $comment = $this->postComment->create($data);
+            $newComment = $this->postComment->create($data);
 
-            if($comment->parent_id){
-                $this->postComment->where('id', $comment->parent_id)->increment('reply_count');
+            if($newComment->parent_id){
+                $this->postComment->where('id', $newComment->parent_id)->increment('reply_count');
             }
 
             DB::commit();
-            if(!$comment->parent_id){
-                Redis::DEL('post_new_comment_'.$comment->post_id);
+            if($newComment->parent_id){
+                Redis::DEL('post_new_reply_'.$newComment->parent_id);
             }else{
-                Redis::DEL('post_new_reply_'.$comment->id);
+                Redis::DEL('post_new_comment_'.$newComment->post_id);
             }
-            return jsonSuccess(['id' => $comment->id], '评论成功');
+            return jsonSuccess(['id' => $newComment->id], '评论成功');
 
         }catch (QueryException $exception){
             DB::rollBack();