fix private channel

This commit is contained in:
2024-05-15 09:56:18 +07:00
parent 86034f6e5e
commit b8fdaf2ada
3 changed files with 87 additions and 7 deletions

View File

@@ -1,7 +1,9 @@
<?php
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\Facades\Auth;
use App\Models\User;
use App\Models\Channel;
/*
|--------------------------------------------------------------------------
| Broadcast Channels
@@ -13,10 +15,10 @@ use Illuminate\Support\Facades\Broadcast;
|
*/
// Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
// return (int) $user->id === (int) $id;
// });
Broadcast::channel('chat.{id}', function ($user, $id) {
return true;
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});
Broadcast::channel('chat.{room_id}', function ($user, $room_id) {
return Auth::check();
});