1. Go to this page and download the library: Download muba00/laravel-live-chat 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/ */
muba00 / laravel-live-chat example snippets
use muba00\LaravelLiveChat\Models\Conversation;
use muba00\LaravelLiveChat\Models\Message;
// Get or create a conversation between two users
$conversation = Conversation::between(auth()->user(), $otherUser);
// Send a message
$message = Message::create([
'conversation_id' => $conversation->id,
'sender_id' => auth()->id(),
'message' => 'Hello! How are you?',
]);
use muba00\LaravelLiveChat\Models\Conversation;
use muba00\LaravelLiveChat\Models\Message;
// Get or create a conversation
$conversation = Conversation::between($user1, $user2);
// Check if a user is part of a conversation
$conversation->> 'Hello!',
]);
// Mark messages as read
$conversation->markAsReadBy(auth()->user());
// Get unread message count
$unreadCount = $conversation->unreadMessagesFor(auth()->user())->count();
// In app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
// Clean up messages older than 90 days, daily at 2 AM
$schedule->command('live-chat:cleanup --days=90 --force')
->dailyAt('02:00');
}
namespace App\Models;
use muba00\LaravelLiveChat\Models\Conversation as BaseConversation;
class Conversation extends BaseConversation
{
// Add your custom methods and properties
}
// In config/live-chat.php
'routes' => [
'enabled' => false,
],
bash
php artisan live-chat:install
bash
php artisan reverb:start
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.