1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 08:04:03 +00:00

reimplement broadcasting channel helpers to support model binding

This commit is contained in:
Samuel Štancl 2024-10-03 21:12:09 +02:00
parent 836a258a78
commit a37dc9b449
2 changed files with 3 additions and 14 deletions

View file

@ -12,6 +12,6 @@ class ModelNotSyncMasterException extends Exception
{
public function __construct(string $class)
{
parent::__construct("Model of $class class is not a SyncMaster model. Make sure you're using the central model to make changes to synced resources when you're in the central context");
parent::__construct("Model of $class class is not a SyncMaster model. Make sure you're using the central model to make changes to synced resources when you're in the central context.");
}
}

View file

@ -112,7 +112,7 @@ if (! function_exists('tenant_channel')) {
function tenant_channel(string $channelName, Closure $callback, array $options = []): void
{
// Register '{tenant}.channelName'
Broadcast::channel('{tenant}.' . $channelName, fn ($user, $tenantKey, ...$args) => $callback($user, ...$args), $options);
Broadcast::channel('{tenant}.' . $channelName, $callback, $options);
}
}
@ -121,17 +121,6 @@ if (! function_exists('global_channel')) {
{
// Register 'global__channelName'
// Global channels are available in both the central and tenant contexts
Broadcast::channel('global__' . $channelName, fn ($user, ...$args) => $callback($user, ...$args), $options);
}
}
if (! function_exists('universal_channel')) {
function universal_channel(string $channelName, Closure $callback, array $options = []): void
{
// Register 'channelName'
Broadcast::channel($channelName, $callback, $options);
// Register '{tenant}.channelName'
tenant_channel($channelName, $callback, $options);
Broadcast::channel('global__' . $channelName, $callback, $options);
}
}