feat: chat en tiempo real bidireccional funcionando con Reverb
This commit is contained in:
+3
-9
@@ -1,17 +1,11 @@
|
||||
<?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();
|
||||
|
||||
Broadcast::channel('chat.{receiverId}', function ($user, $receiverId) {
|
||||
return (int) $user->id === (int) $receiverId;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user