/** * @api {get} /comments/:commentId/replies Get Comment Replies * @apiGroup Post Comments * @apiDescription Get replies to a comment. * * @param Comment $comment * * @return \Illuminate\Http\Response */ public function index(Comment $comment) { $comments = $comment->replies()->orderBy('likeCount', 'DESC')->orderBy('createdAt', 'ASC'); $paginator = $comments->paginate($this->getResultsPerPage()); $array = $this->paginatorToArray($paginator, 'comments'); // FIXME: Did I make this unnecessary already? // Load the replies to top-level comments foreach ($array['comments'] as &$comment) { /** @var Comment $comment */ $comment->load('replies'); } return $this->response($array); }