nahid/talk
Talk adds a full user-to-user conversation system to Laravel: create conversations, threaded messages, pagination, read/seen status, soft/permanent deletes, participant-only access, URL embedding, and optional realtime messaging for chat-like experiences.
Start by installing the package via Composer (composer require nahid/talk) and publishing its assets with php artisan vendor:publish --provider="Nahid\Talk\TalkServiceProvider". Run migrations to set up the required tables (conversation, message, message_user). Configure your user model in config/talk.php, then register the Talk middleware (talk) in app/Http/Kernel.php and apply it to routes where messaging is needed. To begin, inject the authenticated user ID using either Talk::setAuthUserId(auth()->id()) (e.g., in controller constructor) or chain operations with Talk::user(auth()->id())->.... A quick first use is sending a message:
$conversationId = Talk::isConversationExists($receiverId) ?:
Talk::sendMessageByUserId($receiverId, 'Hello!')->conversation_id;
Explore the example app at https://github.com/nahid/talk-example for a working reference.
setAuthUserId()/user() calls to scope all Talk operations to the current user.config/talk.php ('broadcast' => ['enable' => true, ...]) and configure Pusher or laravel-websockets. Listen for Talk\MessageSent events on the frontend using Echo.sendMessageByUserId() if the conversation doesn’t exist yet (creates on-the-fly), or sendMessage() if you already have a conversation_id.Talk::user($id)->threads() or getInbox() retrieves paginated conversation threads with latest messages.getConversationsByUserId($receiverId) or messages($conversationId) for full thread history.$inbox->withUser (user info) and $inbox->thread (latest message) in inbox lists.getConversationsById($id) to load a full conversation with sender info and timestamps.makeSeen($messageId) when user opens a thread; use deleteMessage($messageId) to soft-delete per user (restored via messagesAll* methods).setAuthUserId() or user() is called before querying— Talk defaults to null auth, yielding empty results silently.talk middleware globally unless all routes require auth user scoping; prefer per-controller application.config/broadcasting.php and JS setup.getReceiverInfo() is deprecated—use $message->withUser or $message->sender relationships instead.getInbox() excludes soft-deleted messages; use threadsAll()/getInboxAll() if you need recovery UX (e.g., trash folder).$offset and $take parameters (e.g., threads('desc', 0, 20))—handle pagination in your controller, not the view.oembed in config/talk.php and validate target URLs to embed rich previews—disabled by default.How can I help you explore Laravel packages today?