瀏覽代碼

评论数

wzq 5 年之前
父節點
當前提交
2040c6ea65
共有 1 個文件被更改,包括 6 次插入1 次删除
  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;
     }
 
 }