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

Replies & quoting

Any message can reply to another in the same thread. A lightweight snapshot of the quoted message is stored on the reply, so the quote survives the parent being edited or deleted:

use RoundlyConsulting\Messages\Facades\Messages;

$reply = Messages::to($thread)->from($bob)->replyingTo($original)->send('On it!');

$reply->parent;       // the quoted message (relation)
$original->replies;   // every reply to it
$reply->meta['quote']; // ['id', 'sender_id', 'sender_type', 'excerpt'] snapshot

The snapshot’s excerpt is truncated to preview.length characters (120 by default). Replying to a message in a different thread — or to one that does not exist — throws a MessageException.

Replying through the action

sendMessageTo() on the trait has no reply parameter; use the builder above or pass parentMessageId to the SendMessage action:

use RoundlyConsulting\Messages\Actions\SendMessage;
use RoundlyConsulting\Messages\DataTransferObjects\SendMessageData;

app(SendMessage::class)->execute(new SendMessageData(
    thread: $thread,
    sender: $bob,
    body: 'On it!',
    parentMessageId: $original->getKey(),
));

Rendering replies

MessageResource exposes a reply_to object (id, excerpt, sender_id, sender_type) built from the snapshot, and the Pest expectation toBeReplyTo() asserts the relationship in tests.

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.