kirschbaum-development / nova-inline-relationship

A package to present relationships as inline properties in Nova.
MIT License
198 stars 83 forks source link

Update BelongsToObserver #16

Closed mahentoo closed 4 years ago

mahentoo commented 5 years ago

In cases where it is necessary to create (parent) during editing (model).

brandonferens commented 4 years ago

Thank you @mahentoo for this PR. We are looking over this internally and will let you know if we have any questions are comments!

brandonferens commented 4 years ago

@mahentoo We'd like a couple formatting/reorganization changes. Could you please update the code to look like this:

$parentModel = $model->{$attribute}()->first();

if (empty($parentModel)) {
    return $this->creating($model, $attribute, $value);
}

if (count($value)) {
    $parentModel->update($value[0]);
}

Once that is done, we will merge it in!

mahentoo commented 4 years ago

@brandonferens Done in #29

brandonferens commented 4 years ago

Thanks @mahentoo!