commentService->fetchComments( $postId, $page, $request->filters(), $request->order() ); return response()->json(PaginableResource::make($comments, CommentCollection::class)); } public function store(StoreCommentRequest $request, int $postId): JsonResponse { return response()->json(CommentResource::make($this->commentService->storeComment($request->all(), $postId)), 201); } public function update(UpdateCommentRequest $request, int $postId, int $id): JsonResponse { $comment = $this->commentService->updateComment($request->all(), $postId, $id); if ($comment === null) { return response()->json(null, 404); } return response()->json(CommentResource::make($comment)); } public function destroy(DestroyCommentRequest $post, int $postId, int $id): JsonResponse { $isSuccessfullyDeleted = $this->commentService->deleteComment($postId, $id); return match ($isSuccessfullyDeleted) { false => response()->json(null, 404), true => response()->json(null, 204), }; } }