laravel broadcasting for multiple guard

后端 未结 2 739
南方客
南方客 2021-02-06 17:40

I have the below auth guards that is defined for my app admins, designers, customers and etc. the default guard is the designer guar

2条回答
  •  孤城傲影
    2021-02-06 18:34

    Try changing in BroadcastServiceProvider file app\Providers\BroadcastServiceProvider.php

    Different broadcast auth end point for each guards

    public function boot()
    {
       //Broadcast::routes();
       //match any of the 3 auth guards
       Broadcast::routes(['middleware' => ['web','auth:admins,designers,customers']]);
       require base_path('routes/channels.php');
    }
    

    Now in channels.php

    Broadcast::channel('admins.channel.{id}', function ($model, $id) {
          return $model->id === $id && get_class($model) === 'App\Admin';
    });
    
    Broadcast::channel('designers.channel.{id}', function ($model, $id) {
          return $model->id === $id && get_class($model) === 'App\Designer';
    });
    
    Broadcast::channel('customers.channel.{id}', function ($model, $id) {
          return $model->id === $id && get_class($model) === 'App\Customer';
    });
    

提交回复
热议问题