From d0faea78b22cf8e24c62a16ac767e656fa1c2661 Mon Sep 17 00:00:00 2001 From: ianrobertsFF <91917328+ianrobertsFF@users.noreply.github.com> Date: Sat, 9 Apr 2022 19:04:11 +0100 Subject: [PATCH] Added withoutEvents advisory (#158) Added advisory to let users know that withoutEvents is used when creating resources as a result of a sync. --- source/docs/v3/synced-resources-between-tenants.blade.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/docs/v3/synced-resources-between-tenants.blade.md b/source/docs/v3/synced-resources-between-tenants.blade.md index f028db9..ae0b98b 100644 --- a/source/docs/v3/synced-resources-between-tenants.blade.md +++ b/source/docs/v3/synced-resources-between-tenants.blade.md @@ -26,6 +26,8 @@ You will need two models for the resource. One for the tenant database and one f Both models must use the `ResourceSyncing` trait. This trait makes sure that a `SyncedResourceSaved` event is fired whenever the model is saved. The `UpdateSyncedResource` listener will update the resource in the central database and in all tenant databases where the resource exists. The listener is registered in your `TenancyServiceProvider`. +It is important to note that when a model is updated or created as a result of being synchronised, that model is called with `withoutEvents` and as such if you rely on the saving or creating events you will need to implement this in some other way. + An important requirement of the `Syncable` interface is the `getSyncedAttributeNames()` method. You don't want to sync all columns (or more specifically, attributes, since we're talking about Eloquent models — **accessors & mutators are supported**). In the `users` example, you'd likely only want to sync attributes like the name, email and password, while keeping tenant-specific (or workspace-specific/team-specific, whatever makes sense in your project's terminology) attributes independent. The resource needs to have the same global ID in the central database and in tenant databases.