【发布时间】:2020-07-08 10:40:26
【问题描述】:
我的多租户 laravel 应用程序有多个推送帐户,配置如下:
'pusher_it' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_IT_KEY'),
'secret' => env('PUSHER_APP_IT_SECRET'),
'app_id' => env('PUSHER_APP_IT_ID'),
'options' => [
'cluster' => 'eu',
'useTLS' => true
],
],
'pusher_es' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_ES_KEY'),
'secret' => env('PUSHER_ES_ES_SECRET'),
'app_id' => env('PUSHER_ES_ES_ID'),
'options' => [
'cluster' => 'eu',
'useTLS' => true
],
],
'pusher_pt' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_PT_KEY'),
'secret' => env('PUSHER_APP_PT_SECRET'),
'app_id' => env('PUSHER_APP_PT_ID'),
'options' => [
'cluster' => 'eu',
'useTLS' => true
],
],
当我发送新通知时:
Notification::send($usersToNotify, (new VehicleFailureEstimateNotification($vehicleFailureEstimate))->locale(App::getLocale()));
我会即时设置推送器配置:
class VehicleFailureEstimateNotification extends Notification
{
use Queueable;
/**
* @var VehicleFailureEstimate
*/
private $vehicleFailureEstimate;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(VehicleFailureEstimate $vehicleFailureEstimate)
{
Broadcast::setDefaultDriver('pusher_'.$this->locale);
Broadcast::connection('pusher_'.$this->locale);
$this->vehicleFailureEstimate = $vehicleFailureEstimate;
}
但通知总是通过 .env 默认 BROADCAST_DRIVER=pusher_it 触发
你能帮帮我吗?谢谢
【问题讨论】:
标签: php laravel broadcast pusher