Repository navigation
|
Hello! Need multiple BROADCAST_CONNECTION Example usage:
Now the configuration needs to be updated (global config update)class CorpReportCentEvent implements ShouldBroadcastNow
{
use Dispatchable;
use SerializesModels;
/**
* @param array $message
*/
public function __construct(public array $message)
{
//
config(['broadcasting.default' => CentConnectionEnum::CENT_CORP->value]);
}
...
}What is needed (local update for one event)class CorpReportCentEvent implements ShouldBroadcastNow
{
use Dispatchable;
use SerializesModels;
// If not set $broadcast_connection use default from .env BROADCAST_CONNECTION
public $broadcast_connection = CentConnectionEnum::CENT_CORP->value;
/**
* @param array $message
*/
public function __construct(public array $message) {}
...
} |
Answered by
dxnter
Jan 24, 2026
Replies: 2 comments
|
This is already supported, and you have a few options available. At dispatch time: broadcast(new CorpReportCentEvent($message))->via(CentConnectionEnum::CENT_CORP->value);In the constructor (requires trait): class CorpReportCentEvent implements ShouldBroadcastNow
{
use Dispatchable, SerializesModels, InteractsWithBroadcasting;
public function __construct(public array $message)
{
$this->broadcastVia(CentConnectionEnum::CENT_CORP->value);
}
}Define a method (no trait needed): class CorpReportCentEvent implements ShouldBroadcastNow
{
use Dispatchable, SerializesModels;
public function __construct(public array $message) {}
public function broadcastConnections(): array
{
return [CentConnectionEnum::CENT_CORP->value];
}
}All three avoid mutating global config. Option 3 is closest to what you described with a property based approach. |
0 replies
Answer selected by
Mishanki
|
Work! Thanks! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is already supported, and you have a few options available.
At dispatch time:
In the constructor (requires trait):
Define a method (no trait needed):