fixed recurring cloneable relations type
This commit is contained in:
parent
09e32ad262
commit
84ee8b123a
|
|
@ -218,6 +218,8 @@ class RecurringCheck extends Command
|
||||||
$model->created_from = 'core::recurring';
|
$model->created_from = 'core::recurring';
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
||||||
|
$this->updateRelationTypes($model, $template->cloneable_relations);
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,6 +235,8 @@ class RecurringCheck extends Command
|
||||||
$model->created_from = 'core::recurring';
|
$model->created_from = 'core::recurring';
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
||||||
|
$this->updateRelationTypes($model, $template->cloneable_relations);
|
||||||
|
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,4 +270,15 @@ class RecurringCheck extends Command
|
||||||
{
|
{
|
||||||
return Str::replace('-recurring', '', $recurring_type);
|
return Str::replace('-recurring', '', $recurring_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateRelationTypes($model, $relations)
|
||||||
|
{
|
||||||
|
foreach ($relations as $relation) {
|
||||||
|
if (! method_exists($model, $relation)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$model->$relation()->update(['type' => $model->type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue