Browse Source

评论数

wzq 5 years ago
parent
commit
2040c6ea65
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/Repositories/PostRepositories.php

+ 6 - 1
app/Repositories/PostRepositories.php

@@ -682,7 +682,12 @@ class PostRepositories
      */
     public function getCommentCount($id)
     {
-        return $this->postComment->where('post_id', $id)->count();
+        $commentCount = 0;
+        $post = $this->post->find($id);
+        if($post){
+            $commentCount = $post->data->comment_count;
+        }
+        return $commentCount;
     }
 
 }