### Install Messages for Laravel with Composer and Artisan Source: https://github.com/roundly-consulting/messages-for-laravel/blob/main/README.md Run these commands to install the package and publish the required migrations. Requires PHP 8.4 and Laravel 12 or 13. Publish both media and messages migrations; every send reads the bundled media-library's media table. If your participating models use UUID/ULID keys, set MESSAGES_KEY_TYPE=uuid or ulid before migrating. ```bash composer require roundly-consulting/messages-for-laravel php artisan vendor:publish --tag="media-migrations" php artisan vendor:publish --tag="messages-migrations" php artisan migrate ``` -------------------------------- ### Start conversations, send messages, and track unread counts Source: https://github.com/roundly-consulting/messages-for-laravel/blob/main/README.md Shows the core messaging API: start a group thread, send messages, create or find a direct message, and query unread counts, mark as read, and fetch the inbox. The first participant in withParticipants owns the group thread. direct() returns one DM per pair, found or created. unreadCount returns the number of unread messages. inboxFor returns newest activity first with unread counts loaded. ```php 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 ``` -------------------------------- ### Enable messaging on an Eloquent model with HasMessaging Source: https://github.com/roundly-consulting/messages-for-laravel/blob/main/README.md Implement ParticipatesInMessaging and use the HasMessaging trait to let a model take part in conversations. The participateAs method must return an array with 'id' and 'name' keys. ```php 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]; } } ```