Skip to content

Commit fb9fb33

Browse files
Update MorphTo.php
1 parent 50a9b28 commit fb9fb33

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Fields/MorphTo.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,15 @@ public function fill(NovaRequest $request, object $model)
313313

314314
$foreignKey = $this->getRelationForeignKeyName($model->{$this->attribute}());
315315

316+
if ($model->isDirty([$morphType, $foreignKey])) {
317+
$model->unsetRelation($this->attribute);
318+
}
319+
316320
parent::fillInto($request, $model, $foreignKey);
317321

318322
if (is_null($model->{$this->attribute.'_type'})) {
319323
$model->{$this->attribute.'_id'} = null;
320324
}
321-
322-
if ($model->isDirty([$morphType, $foreignKey])) {
323-
$model->unsetRelation($this->attribute);
324-
}
325325
}
326326

327327
/**

0 commit comments

Comments
 (0)