Files
eatvio-infra/routes/channels.php
2023-05-22 09:52:08 +00:00

24 lines
701 B
PHP

<?php
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\Str;
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
Broadcast::channel('direct-chat.{id}', function ($user, $id) {
// return (int) $user->id === (int) $id;
$peers = Str::of($id)->explode('_')->toArray();
return in_array($user->id, $peers);
/* return true; */
});