NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

Drop-in JSON for SPA and mobile backends:

use RoundlyConsulting\Comments\Http\Resources\CommentResource;

return CommentResource::collection(
    $post->threadedComments()->with(['actor', 'likes', 'media'])->get(),
);
FieldContent
idThe comment id.
bodyThe comment body.
statuspending, approved or hidden.
visibleThe visibility flag.
parent_idThe parent comment id, or null.
lockedWhether the comment’s own thread lock is set.
author{ type, id } of the actor — only when actor is loaded.
likes{ count, viewer_state, breakdown } — only when likes is loaded.
attachments[{ id, url }] (media UUID + URL, signed for private attachments) — only when media is loaded.
repliesNested CommentResource items — only when replies are loaded.
created_at / updated_atISO 8601 timestamps.

threadedComments() is the public thread, so the JSON holds only visible + approved roots and replies. The resource renders whatever it is given — the replies key is any loaded replies relation — so on public endpoints feed it a public query: threadedComments(), or a visible() CommentQuery with withReplies().

The likes payload is rendered without a viewer, so viewer_state is the guest state — for per-viewer data use withLikedState($viewer) on the query or likeState($viewer). Attachment URLs are resolved by each attachment’s visibility — signed and short-lived for private ones.

Collections & pagination

CommentCollection collects CommentResource and works with paginated results too:

use RoundlyConsulting\Comments\Facades\Comments;
use RoundlyConsulting\Comments\Http\Resources\CommentCollection;

return new CommentCollection(
    Comments::for($post)->visible()->rootsOnly()->withReplies()->paginate(20),
);

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.