18 lines
464 B
PHP
18 lines
464 B
PHP
<?php
|
|
use Illuminate\Support\Facades\Broadcast;
|
|
use App\Models\Conversation;
|
|
|
|
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
|
return (int) $user->id === (int) $id;
|
|
});
|
|
|
|
Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {
|
|
|
|
return Conversation::where('id', $conversationId)
|
|
->whereHas('users', function ($q) use ($user) {
|
|
$q->where('user_id', $user->id);
|
|
})
|
|
->exists();
|
|
|
|
});
|