1. Go to this page and download the library: Download metafroliclabs/laravel-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/ */
'user' => [
'name_cols' => ['first_name', 'last_name'], // Columns to build full name
'image_col' => 'avatar', // Column for profile picture
'enable_image_url' => true, // If true, image will be URL
]
'rate_limits' => [
'chat_creation_per_minute' => 20, // Max 20 chats per user per minute
'messages_per_minute' => 40 // Max 40 messages per user per minute
],
public MessageSent(Chat $chat, array $messages, User $sender, array $receiver)
namespace App\Listeners;
use Metafroliclabs\LaravelChat\Events\MessageSent;
use Illuminate\Contracts\Queue\ShouldQueue;
class HandleMessageSent implements ShouldQueue
{
public function handle(MessageSent $event)
{
$chat = $event->chat;
$messages = $event->messages;
$sender = $event->sender;
$receivers = $event->receivers;
// Example: Send push notifications or log activity
}
}