mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 13:54:03 +00:00
reimplement broadcasting channel helpers to support model binding
This commit is contained in:
parent
836a258a78
commit
a37dc9b449
2 changed files with 3 additions and 14 deletions
|
|
@ -12,6 +12,6 @@ class ModelNotSyncMasterException extends Exception
|
||||||
{
|
{
|
||||||
public function __construct(string $class)
|
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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ if (! function_exists('tenant_channel')) {
|
||||||
function tenant_channel(string $channelName, Closure $callback, array $options = []): void
|
function tenant_channel(string $channelName, Closure $callback, array $options = []): void
|
||||||
{
|
{
|
||||||
// Register '{tenant}.channelName'
|
// 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'
|
// Register 'global__channelName'
|
||||||
// Global channels are available in both the central and tenant contexts
|
// Global channels are available in both the central and tenant contexts
|
||||||
Broadcast::channel('global__' . $channelName, fn ($user, ...$args) => $callback($user, ...$args), $options);
|
Broadcast::channel('global__' . $channelName, $callback, $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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue