22 lines
665 B
PHP
22 lines
665 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', fn ($q) =>
|
|
$q->where('user_id', $user->id)
|
|
)->exists();
|
|
});
|
|
|
|
|
|
|
|
|
|
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();});
|