-
- $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));
+
+ $comments = $this->commentRepo->getPageComments($pageId);
+ return response()->json(['status' => 'success', 'comments'=> $comments['comments'],
+ 'total' => $comments['total'], 'permissions' => [
+ 'comment_create' => $this->currentUser->can('comment-create-all'),
+ 'comment_update_own' => $this->currentUser->can('comment-update-own'),
+ 'comment_update_all' => $this->currentUser->can('comment-update-all'),
+ 'comment_delete_all' => $this->currentUser->can('comment-delete-all'),
+ 'comment_delete_own' => $this->currentUser->can('comment-delete-own'),
+ ], 'user_id' => $this->currentUser->id]);