1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 10:34:04 +00:00

create config key

This commit is contained in:
Ovidiu Popescu 2023-02-09 14:10:49 +02:00
parent 7a8baad3ca
commit c9147b5849
No known key found for this signature in database
GPG key ID: D939DC6D2AD0AB09
2 changed files with 9 additions and 1 deletions

View file

@ -196,4 +196,9 @@ return [
'--class' => 'DatabaseSeeder', // root seeder class '--class' => 'DatabaseSeeder', // root seeder class
// '--force' => true, // '--force' => true,
], ],
/**
* Allow the resource be created in the central DB just with the synced attributes.
*/
'created_only_with_synced_attributes' => false,
]; ];

View file

@ -60,7 +60,10 @@ class UpdateSyncedResource extends QueueableListener
} else { } else {
// If the resource doesn't exist at all in the central DB,we create // If the resource doesn't exist at all in the central DB,we create
// the record with all attributes, not just the synced ones. // 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)); event(new SyncedResourceChangedInForeignDatabase($event->model, null));
} }
}); });