diff --git a/assets/config.php b/assets/config.php index b12cd6c4..7e51d9f5 100644 --- a/assets/config.php +++ b/assets/config.php @@ -196,4 +196,9 @@ return [ '--class' => 'DatabaseSeeder', // root seeder class // '--force' => true, ], + + /** + * Allow the resource be created in the central DB just with the synced attributes. + */ + 'created_only_with_synced_attributes' => false, ]; diff --git a/src/Listeners/UpdateSyncedResource.php b/src/Listeners/UpdateSyncedResource.php index 604b17cf..b17e49a6 100644 --- a/src/Listeners/UpdateSyncedResource.php +++ b/src/Listeners/UpdateSyncedResource.php @@ -60,7 +60,10 @@ class UpdateSyncedResource extends QueueableListener } else { // If the resource doesn't exist at all in the central DB,we create // the record with all attributes, not just the synced ones. - $centralModel = $event->model->getCentralModelName()::create($syncedAttributes); + $centralModel = $event->model->getCentralModelName()::create( + config('tenancy.created_only_with_synced_attributes') ? $syncedAttributes + : $event->model->getAttributes() + ); event(new SyncedResourceChangedInForeignDatabase($event->model, null)); } });