Realtime messages between entities using Laravel broadcasting
roundly-consulting/messages-for-laravel is a Laravel package for realtime messages between entities using laravel broadcasting.
It currently has 6 GitHub stars and 13 downloads on Packagist (latest version 1.2.0).
Install it with composer require roundly-consulting/messages-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
A direct-message and group-chat foundation for any Laravel app. Give any Eloquent model a one-line messaging API with read receipts, unread counts, roles and attachments, react to plain Laravel events, and optionally broadcast threads, messages and typing in real time.
Requires PHP 8.4 and Laravel 12 or 13.
composer require roundly-consulting/messages-for-laravel
php artisan vendor:publish --tag="media-migrations"
php artisan vendor:publish --tag="messages-migrations"
php artisan migrate
Publish both tags: every send reads the bundled media-library's media table. If your
participating models (usually User) have UUID/ULID keys, set MESSAGES_KEY_TYPE=uuid (or
ulid) before migrating.
Let a model take part in conversations:
use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Messages\Concerns\HasMessaging;
use RoundlyConsulting\Messages\Interfaces\ParticipatesInMessaging;
class User extends Model implements ParticipatesInMessaging
{
use HasMessaging;
public function participateAs(): array
{
return ['id' => $this->id, 'name' => $this->name];
}
}
Then start conversations, send, and track what is unread:
use RoundlyConsulting\Messages\Facades\Messages;
$thread = Messages::start('Launch')
->withParticipants([$alice, $bob]) // $alice, the first, owns the group thread
->create();
Messages::to($thread)->from($alice)->send('Hello');
$dm = Messages::direct($alice, $bob); // one DM per pair, found or created
Messages::send($dm, $bob, 'Hi Alice!');
Messages::unreadCount($bob); // 1
Messages::markRead($thread, $bob);
Messages::inboxFor($bob, perPage: 20); // newest activity first, unread counts loaded
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/messages-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
The MIT License (MIT). See LICENSE.md.