Search by

roundly-consulting / messages-for-laravel

mihaliak

Realtime messages between entities using Laravel broadcasting

Package info

github.com/roundly-consulting/messages-for-laravel

pkg:composer/roundly-consulting/messages-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 18:13 UTC

This package is auto-updated.

Last update: 2026-10-03 18:35:27 UTC


README

Messages for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

Messages for Laravel

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.

Installation

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.

Usage

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

Documentation

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.

Support our work

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.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

The MIT License (MIT). See LICENSE.md.