mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 01:44:04 +00:00
method rename
This commit is contained in:
parent
4245f46bc1
commit
b17882fcf8
4 changed files with 10 additions and 10 deletions
|
|
@ -16,5 +16,5 @@ interface Syncable
|
||||||
|
|
||||||
public function triggerSyncEvent(): void;
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ trait ResourceSyncing
|
||||||
event(new SyncedResourceSaved($this, tenant()));
|
event(new SyncedResourceSaved($this, tenant()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCreationAttributes(): array|null
|
public function getSyncedCreationAttributes(): array|null
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,18 +123,18 @@ class UpdateSyncedResource extends QueueableListener
|
||||||
|
|
||||||
protected function getAttributesForCreation(Syncable $model): array
|
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
|
// Creation attributes are not specified so create the model as 1:1 copy
|
||||||
return $model->getAttributes();
|
return $model->getAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Arr::isAssoc($model->getCreationAttributes())) {
|
if (Arr::isAssoc($model->getSyncedCreationAttributes())) {
|
||||||
// Developer provided the default values
|
// Developer provided the default values
|
||||||
// We will merge the default values with sync attributes
|
// 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
|
// Developer provided the attribute names, so we'd use them to pick model attributes
|
||||||
return $model->only($model->getCreationAttributes());
|
return $model->only($model->getSyncedCreationAttributes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -820,7 +820,7 @@ class ResourceUser extends Model implements Syncable
|
||||||
|
|
||||||
// override method in ResourceUser class to return attribute default values
|
// override method in ResourceUser class to return attribute default values
|
||||||
class ResourceUserWithDefaultValues extends ResourceUser {
|
class ResourceUserWithDefaultValues extends ResourceUser {
|
||||||
public function getCreationAttributes(): array
|
public function getSyncedCreationAttributes(): array
|
||||||
{
|
{
|
||||||
// Attributes default values when creating resources from tenant to central DB
|
// Attributes default values when creating resources from tenant to central DB
|
||||||
return
|
return
|
||||||
|
|
@ -832,7 +832,7 @@ class ResourceUserWithDefaultValues extends ResourceUser {
|
||||||
|
|
||||||
// override method in ResourceUser class to return attribute names
|
// override method in ResourceUser class to return attribute names
|
||||||
class ResourceUserWithAttributeNames extends ResourceUser {
|
class ResourceUserWithAttributeNames extends ResourceUser {
|
||||||
public function getCreationAttributes(): array
|
public function getSyncedCreationAttributes(): array
|
||||||
{
|
{
|
||||||
// Attributes used when creating resources from tenant to central DB
|
// Attributes used when creating resources from tenant to central DB
|
||||||
// Notice here we are not adding "code" filed because it doesn't
|
// Notice here we are not adding "code" filed because it doesn't
|
||||||
|
|
@ -851,7 +851,7 @@ class ResourceUserWithAttributeNames extends ResourceUser {
|
||||||
|
|
||||||
// override method in CentralUser class to return attribute default values
|
// override method in CentralUser class to return attribute default values
|
||||||
class CentralUserWithDefaultValues extends CentralUser {
|
class CentralUserWithDefaultValues extends CentralUser {
|
||||||
public function getCreationAttributes(): array
|
public function getSyncedCreationAttributes(): array
|
||||||
{
|
{
|
||||||
// Attributes default values when creating resources from central to tenant model
|
// Attributes default values when creating resources from central to tenant model
|
||||||
return
|
return
|
||||||
|
|
@ -863,7 +863,7 @@ class CentralUserWithDefaultValues extends CentralUser {
|
||||||
|
|
||||||
// override method in CentralUser class to return attribute names
|
// override method in CentralUser class to return attribute names
|
||||||
class CentralUserWithAttributeNames extends CentralUser {
|
class CentralUserWithAttributeNames extends CentralUser {
|
||||||
public function getCreationAttributes(): array
|
public function getSyncedCreationAttributes(): array
|
||||||
{
|
{
|
||||||
// Attributes used when creating resources from central to tenant DB
|
// Attributes used when creating resources from central to tenant DB
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue