BroadcastServiceProvider.php 478 Bytes
<?php

namespace App\Providers;

use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;

class BroadcastServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(): void
    {
        Broadcast::routes();

        Broadcast::channel('App.Models.User.{id}', static function ($user, $id) {
            return (int)$user->id === (int)$id;
        });
    }
}