diff --git a/src/ResourceSyncing/TriggerSyncingEvents.php b/src/ResourceSyncing/TriggerSyncingEvents.php index dada31db..b59a9550 100644 --- a/src/ResourceSyncing/TriggerSyncingEvents.php +++ b/src/ResourceSyncing/TriggerSyncingEvents.php @@ -22,9 +22,9 @@ trait TriggerSyncingEvents public static function bootTriggerSyncingEvents(): void { static::saving(static function (self $pivot) { - // Try getting the central resource to see if it is available - // If it is not available, throw an exception to interrupt the saving process - // And prevent creating a pivot record without a central resource + // Try getting the central resource to see if it is available. + // If it is not, getCentralResourceAndTenant() throws (indirectly, via findCentralResource() -> getResourceClass()), + // interrupting the save, preventing the creation of a pivot record without a central resource. $pivot->getCentralResourceAndTenant(); }); @@ -56,6 +56,10 @@ trait TriggerSyncingEvents }); } + /** + * @throws CentralResourceNotAvailableInPivotException Throws when the tenant is the pivot parent + * but the central resource class cannot be resolved (thrown indirectly via findCentralResource() -> getResourceClass()) + */ public function getCentralResourceAndTenant(): array { /** @var $this&Pivot $this */