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:
parent
db4a795c3e
commit
b90fb6ec77
4 changed files with 82 additions and 2 deletions
|
|
@ -15,4 +15,6 @@ interface Syncable
|
|||
public function getSyncedAttributeNames(): array;
|
||||
|
||||
public function triggerSyncEvent();
|
||||
|
||||
public function getCreateAttributeNames(): array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue