---
title: "Broadcasting — Messages for Laravel | Roundly"
description: "Push threads, participants, messages and typing live over Reverb, Pusher or Ably — off by default, fully configurable channels and names."
url: https://roundly-consulting.com/open-source/docs/messages-for-laravel/broadcasting
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Messages for Laravel](https://roundly-consulting.com/open-source/docs/messages-for-laravel.md)

# Broadcasting

Broadcasting is off by default — the plain events still fire either way. Turn it on to push changes live over Laravel broadcasting (Reverb, Pusher, Ably, …):

```bash
REALTIME_MESSAGES=true
```

When enabled, the Thread, Participant and Message models use Laravel’s BroadcastsEvents on create, update, delete and restore. A new thread is announced once its participants are in, so a private thread reaches every one of them. A soft delete — an unsend or a leave — fires both of Laravel’s trashed and deleted model events but goes out once, as trashed; a force delete goes out once, as deleted.

A thread broadcasts only its creation: renaming, archiving or deleting one is not broadcast. React to the ThreadRenamed and ThreadArchived events to push those yourself — or enable system messages, which posts a (broadcast) “renamed” message into the thread.

## Channels

| Channel | Type | Carries |
| --- | --- | --- |
| `messaging` | public | messaging.thread.created for public threads. |
| `messaging.participant.{name}.{id}` | private | messaging.thread.created for private and direct threads — once per participant: {id} is its key, {name} its lowercased class basename (e.g. user) and {type} its full morph type (see below). |
| `messaging.thread.{id}` | private | Participant events (joined, read, left), message events (sent, updated, unsent, restored) and typing. |

The package registers no channel authorization callbacks — authorize the private channels in your app’s routes/channels.php, for example by checking that the user is a participant of the thread (Thread::query()->forParticipant($user)).

## Channel and event names

Every channel and event name is configurable:

```php
'broadcasting' => [
    'enabled' => env('REALTIME_MESSAGES', false),

    'threads' => [
        'public-channel' => 'messaging',
        'per-participant-channel' => 'messaging.participant.{name}.{id}',   // {name}, {type} or {id}
        'events' => [
            'created' => 'messaging.thread.created',
        ],
    ],

    'participants' => [
        'channel' => 'messaging.thread.{id}',
        'events' => [
            'created' => 'messaging.participant.joined',
            'updated' => 'messaging.participant.read',
            'trashed' => 'messaging.participant.left',
            'restored' => 'messaging.participant.joined',
            'deleted' => 'messaging.participant.left',
        ],
    ],

    'typing' => [
        'event' => 'messaging.participant.typing',
    ],

    'messages' => [
        'channel' => 'messaging.thread.{id}',
        'events' => [
            'created' => 'messaging.message.sent',
            'updated' => 'messaging.message.updated',
            'trashed' => 'messaging.message.unsent',
            'restored' => 'messaging.message.restored',
            'deleted' => 'messaging.message.unsent',
        ],
    ],
],
```

## Per-participant channel placeholders

The per-participant channel takes three placeholders: {id} is the participant’s key; {name} its lowercased class basename (App\\Models\\User → user); {type} its full morph type, lowercased with \\ as . (app.models.user, or the alias itself under a morph map). Without a morph map, two models sharing a basename — App\\Models\\User and App\\Models\\Admin\\User — share a {name} channel and each hears the other’s thread.created announcements. Switch to {type} and authorise that channel in routes/channels.php, or register a morph map:

```php
// config/messages.php — 'broadcasting' => [ 'threads' => [ … ] ]
'per-participant-channel' => 'messaging.participant.{type}.{id}',
// App\Models\Admin\User #5 → private-messaging.participant.app.models.admin.user.5
```

## Payloads

- Thread — id, name, is\_public, everyone\_can\_join.
- Participant — id, participant (participateAs()), read\_at, joined\_at, left\_at.
- Message — id, sender (participateAs()), message (null once unsent), sent\_at, updated\_at, deleted\_at.
- Typing — thread\_id, participant (participateAs()).

## Typing indicators

Broadcast a live typing indicator on the thread channel — it only broadcasts (never persists), respects broadcasting.enabled, and refuses anyone who is not a current participant with a ParticipationException, whether or not broadcasting is on:

```php
use RoundlyConsulting\Messages\Facades\Messages;

Messages::thread($thread)->typing($user);   // broadcasts ParticipantTyping — never persisted
$thread->typing($user);                     // the same, from the model
```

## 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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/messages-for-laravel.md)
