parent::__construct();
}
- public function save(Request $request, $pageId, $commentId)
+ public function save(Request $request, $pageId, $commentId = null)
{
$this->validate($request, [
'text' => 'required|string',
$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));
}
}