From 52f0196fd3f99113fb838f813564e0c78f133b4d Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 30 Dec 2016 15:46:01 -0600 Subject: [PATCH] Move broadcast channel registration to a routes file. These are very similar to routes in that they are channel endpoints that your application supports and they also fully support route model binding in Laravel 5.4. Upgraded applications do not need to make this change if they do not want to. --- app/Providers/BroadcastServiceProvider.php | 7 +------ config/app.php | 1 + routes/channels.php | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 routes/channels.php diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index ee67f771414..352cce44a3d 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -16,11 +16,6 @@ public function boot() { Broadcast::routes(); - /* - * Authenticate the user's personal channel... - */ - Broadcast::channel('App.User.{userId}', function ($user, $userId) { - return (int) $user->id === (int) $userId; - }); + require base_path('routes/channels.php'); } } diff --git a/config/app.php b/config/app.php index b3f0991aa8a..3036ac7cb4a 100644 --- a/config/app.php +++ b/config/app.php @@ -196,6 +196,7 @@ 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, diff --git a/routes/channels.php b/routes/channels.php new file mode 100644 index 00000000000..f16a20b9bfc --- /dev/null +++ b/routes/channels.php @@ -0,0 +1,16 @@ +id === (int) $id; +});