mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 03:54:03 +00:00
rename method to getAttributesForCreation
This commit is contained in:
parent
eef51f40b9
commit
b437f64e30
1 changed files with 3 additions and 5 deletions
|
|
@ -60,7 +60,7 @@ class UpdateSyncedResource extends QueueableListener
|
||||||
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
||||||
} 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
|
||||||
$centralModel = $event->model->getCentralModelName()::create($this->getResourceCreationAttributes($event->model));
|
$centralModel = $event->model->getCentralModelName()::create($this->getAttributesForCreation($event->model));
|
||||||
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
event(new SyncedResourceChangedInForeignDatabase($event->model, null));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -113,7 +113,7 @@ class UpdateSyncedResource extends QueueableListener
|
||||||
$localModel->update($syncedAttributes);
|
$localModel->update($syncedAttributes);
|
||||||
} else {
|
} else {
|
||||||
// When creating, we use all columns, not just the synced ones.
|
// When creating, we use all columns, not just the synced ones.
|
||||||
$localModel = $localModelClass::create($this->getResourceCreationAttributes($eventModel));
|
$localModel = $localModelClass::create($this->getAttributesForCreation($eventModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
event(new SyncedResourceChangedInForeignDatabase($localModel, $tenant));
|
event(new SyncedResourceChangedInForeignDatabase($localModel, $tenant));
|
||||||
|
|
@ -121,13 +121,11 @@ class UpdateSyncedResource extends QueueableListener
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getResourceCreationAttributes(Syncable $model): array
|
protected function getAttributesForCreation(Syncable $model): array
|
||||||
{
|
{
|
||||||
$attributes = $model->getAttributes();
|
$attributes = $model->getAttributes();
|
||||||
|
|
||||||
if ($model->getResourceCreationAttributes()) {
|
if ($model->getResourceCreationAttributes()) {
|
||||||
// If function returned array is key-value, We assume default values are provided
|
|
||||||
// if array is plain values, fetch attributes from model
|
|
||||||
$attributes = Arr::isAssoc($model->getResourceCreationAttributes()) ? $model->getResourceCreationAttributes() : $model->only($model->getResourceCreationAttributes());
|
$attributes = Arr::isAssoc($model->getResourceCreationAttributes()) ? $model->getResourceCreationAttributes() : $model->only($model->getResourceCreationAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue