php - How to set a broadcast driver in the event of laravel?
one text
I have an event like this
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NotifyUser implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
protected $user_id;
public $message;
public $link;
public $notification_id;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($notification)
{
$this->notification_id = $notification->id;
$this->user_id = $notification->user_id;
$this->message = $notification->message;
$this->link = $notification->link;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('notification.user.'.trim($this->user_id));
}
}
And I have configured both pusher and mercury, is it possible to choose which broadcasting driver to use per event? Instead of always using the default?
Source