PHP code example of nnixon / laravel-simple-realtime-chat

1. Go to this page and download the library: Download nnixon/laravel-simple-realtime-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/ */

    

nnixon / laravel-simple-realtime-chat example snippets


// Uncomment this line in the providers array
App\Providers\BroadcastServiceProvider::class,



use App\Models\Conversation;
use App\Models\User;
use Illuminate\Support\Facades\Broadcast;

Broadcast::channel('conversation.{conversationId}', function (User $user, $conversationId) {
    return $user->conversations->contains(function ($conversation) use ($conversationId) {
        return $conversation->id == $conversationId;
    });
});
bash
php artisan realtime-chat:publish
bash
php artisan migrate