From 9fd72c6ea42854e0b59c767498a6bea7134e13ab Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sun, 11 Jan 2026 12:06:27 +0100 Subject: [PATCH] multiplex user notifications over a single private channel --- app/Http/Controllers/UserController.php | 2 -- routes/channels.php | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 6925f3c..bf4fb6f 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -52,9 +52,7 @@ class UserController extends Controller $admins->pluck('id')->toArray() ); - Log::info('Broadcasting UserCreated event', ['user_id' => $user->id]); broadcast(new UserCreated($user)); - Log::info('Event broadcasted'); return response()->json(['message' => 'User created successfully']); } diff --git a/routes/channels.php b/routes/channels.php index 5e365ef..e819e24 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -7,4 +7,6 @@ Broadcast::channel('users.registration', function ($user) { return in_array($user->role, [1, 2]); }); - +Broadcast::channel('user.{id}', function ($user, $id) { + return (int) $user->id === (int) $id; +});