wzq пре 5 година
родитељ
комит
a37d6dee02
1 измењених фајлова са 13 додато и 13 уклоњено
  1. 13 13
      app/Repositories/Post/PostRepository.php

+ 13 - 13
app/Repositories/Post/PostRepository.php

@@ -444,18 +444,18 @@ class PostRepository
         }
         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);
             }
             $virus = $this->behavior->where('behavior_identification', 'comment')->first();
             if ($virus) {
@@ -472,16 +472,16 @@ class PostRepository
                     'post_author_uid' => $post->uid,
                     'post_desc' => $desc,
                     'post_cover' => $post->img,
-                    'comment_id' => $comment->id,
-                    'comment_content' => $comment->content,
-                    'parent_comment_id' => $comment->parent_id,
+                    'comment_id' => $newComment->id,
+                    'comment_content' => $newComment->content,
+                    'parent_comment_id' => $newComment->parent_id,
                     'parent_comment_content' => $parentCommentContent,
                     'parent_comment_uid' => $parentCommentUid,
                     'parent_comment_time' => $parentCommentTime,
-                    'reply_uid' => $comment->reply_uid,
-                    'reply_username' => $comment->reply_username,
-                    'target_id' => $comment->uid,
-                    'action_id' => $comment->id,
+                    'reply_uid' => $newComment->reply_uid,
+                    'reply_username' => $newComment->reply_username,
+                    'target_id' => $newComment->uid,
+                    'action_id' => $newComment->id,
                 ]);
             }
             return Response::create();