From a37dc9b44963eaf4ed8008e4d86dfdb24b3f6bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Thu, 3 Oct 2024 21:12:09 +0200 Subject: [PATCH] reimplement broadcasting channel helpers to support model binding --- .../ModelNotSyncMasterException.php | 2 +- src/helpers.php | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/ResourceSyncing/ModelNotSyncMasterException.php b/src/ResourceSyncing/ModelNotSyncMasterException.php index 1022b054..4ddf7a55 100644 --- a/src/ResourceSyncing/ModelNotSyncMasterException.php +++ b/src/ResourceSyncing/ModelNotSyncMasterException.php @@ -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."); } } diff --git a/src/helpers.php b/src/helpers.php index 35abeaf7..91d55910 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -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); } }