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

method rename

This commit is contained in:
Abrar Ahmad 2022-09-12 11:10:12 +05:00
parent 4245f46bc1
commit b17882fcf8
4 changed files with 10 additions and 10 deletions

View file

@ -16,5 +16,5 @@ interface Syncable
public function triggerSyncEvent(): void;
public function getCreationAttributes(): array|null; // todo come up with a better name
public function getSyncedCreationAttributes(): array|null; // todo come up with a better name
}

View file

@ -33,7 +33,7 @@ trait ResourceSyncing
event(new SyncedResourceSaved($this, tenant()));
}
public function getCreationAttributes(): array|null
public function getSyncedCreationAttributes(): array|null
{
return null;
}

View file

@ -123,18 +123,18 @@ class UpdateSyncedResource extends QueueableListener
protected function getAttributesForCreation(Syncable $model): array
{
if (! $model->getCreationAttributes()) {
if (! $model->getSyncedCreationAttributes()) {
// Creation attributes are not specified so create the model as 1:1 copy
return $model->getAttributes();
}
if (Arr::isAssoc($model->getCreationAttributes())) {
if (Arr::isAssoc($model->getSyncedCreationAttributes())) {
// Developer provided the default values
// We will merge the default values with sync attributes
return array_merge($model->getCreationAttributes(), $model->only($model->getSyncedAttributeNames()));
return array_merge($model->getSyncedCreationAttributes(), $model->only($model->getSyncedAttributeNames()));
}
// Developer provided the attribute names, so we'd use them to pick model attributes
return $model->only($model->getCreationAttributes());
return $model->only($model->getSyncedCreationAttributes());
}
}