PHP code example of ritechoice23 / laravel-chat-engine
1. Go to this page and download the library: Download ritechoice23/laravel-chat-engine library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ritechoice23 / laravel-chat-engine example snippets
use Ritechoice23\ChatEngine\Traits\CanChat;
class User extends Authenticatable
{
use CanChat;
}
use Ritechoice23\ChatEngine\Facades\Chat;
// Create a thread
$thread = Chat::thread()->between($userA, $userB)->create();
// Send a message
$message = Chat::message()
->from($userA)
->to($thread)
->text('Hello!')
->send();
// React to message
$userB->react($message, '❤️');
// Bookmark message
$userB->saveItem($message);
// Mark as read
$message->markAsReadBy($userB);