]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/CommentController.php
#47 - Adds functionality to display child comments. Also has some code towards the...
[bookstack] / app / Http / Controllers / CommentController.php
index 3df4417668bca6cc84ba863893d2aab2c3e8ba11..b8cf776213cd673cb14077d7057d773d9d6b4296 100644 (file)
@@ -85,7 +85,11 @@ class CommentController extends Controller
         $this->checkOwnablePermission('page-view', $page);
         
         $comments = $this->commentRepo->getCommentsForPage($pageId, $commentId);
-        
+        if (empty($commentId)) {
+            // requesting for parent level comments, send the total count as well.
+            $totalComments = $this->commentRepo->getCommentCount($pageId);
+            return response()->json(array('success' => true, 'comments'=> $comments, 'total' => $totalComments));
+        }
         return response()->json(array('success' => true, 'comments'=> $comments));
     }
 }