This package allows you to add a chat system to your Laravel 5 application
From the command line, run:
composer require musonza/chat
Add the service provider to your config\app.php
the providers array
Musonza\Chat\ChatServiceProvider
You can use the facade for shorter code. Add this to your aliases:
'Chat' => Musonza\Chat\Facades\ChatFacade::class to your `config\app.php`
The class is bound to the ioC as chat
$chat = App::make('chat');
Publish the assets:
php artisan vendor:publish
This will publish database migrations and a configuration file chat.php
in the Laravel config folder.
By default the package assumes you have a User model in the App namespace. However, you can update the
user model in 'chat.php' published in the config
folder.
$conversation = Chat::createConversation([$userId, $userId2,...]); //takes an array of user ids
$conversation = Chat::conversation($conversation_id);
Chat::send($conversation->id, 'Hello', $userId); //$userId sending a message to created conversation
Chat::messageRead($messageId, $userId); //$userId marks the mesage as read
Chat::conversationRead($conversation->id, $userId);
Chat::trash($messageId, $userId);
Chat::clear($conversation->id, $userId);
Chat::getConversationBetweenUsers($userId, $userId2);
Chat::removeParticipants($conversation->id, $usersId); //removing one user
Chat::removeParticipants($conversation->id, [$usersId, $userId2]); //removing multiple users
Chat::addParticipants($conversation->id, $userId3); //add one user
Chat::addParticipants($conversation->id, [$userId3, $userId4]); //add multiple users
Chat::messages($userId, $conversation->id, $perPage, $page);
$mesages = Chat::conversations($userId);
$users = $conversation->users;