multiplex user notifications over a single private channel

This commit is contained in:
2026-01-11 12:06:27 +01:00
parent 9b70b09173
commit 9fd72c6ea4
2 changed files with 3 additions and 3 deletions
-2
View File
@@ -52,9 +52,7 @@ class UserController extends Controller
$admins->pluck('id')->toArray() $admins->pluck('id')->toArray()
); );
Log::info('Broadcasting UserCreated event', ['user_id' => $user->id]);
broadcast(new UserCreated($user)); broadcast(new UserCreated($user));
Log::info('Event broadcasted');
return response()->json(['message' => 'User created successfully']); return response()->json(['message' => 'User created successfully']);
} }
+3 -1
View File
@@ -7,4 +7,6 @@ Broadcast::channel('users.registration', function ($user) {
return in_array($user->role, [1, 2]); return in_array($user->role, [1, 2]);
}); });
Broadcast::channel('user.{id}', function ($user, $id) {
return (int) $user->id === (int) $id;
});