1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-16 10:34:02 +00:00

configure attributes for creating resource

This commit is contained in:
Abrar Ahmad 2022-08-08 16:55:27 +05:00
parent db4a795c3e
commit b90fb6ec77
4 changed files with 82 additions and 2 deletions

View file

@ -15,4 +15,6 @@ interface Syncable
public function getSyncedAttributeNames(): array;
public function triggerSyncEvent();
public function getCreateAttributeNames(): array;
}

View file

@ -58,8 +58,7 @@ class UpdateSyncedResource extends QueueableListener
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
} 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($event->model->getAttributes());
$centralModel = $event->model->getCentralModelName()::create($event->model->only($event->model->getCreateAttributeNames()));
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
}
});