Skip to content

Commit

Permalink
fix -- BelongsToHandler support of mute events for old laravel versions
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix committed Jan 16, 2021
1 parent 3edca08 commit 9c3b36d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Domain/Relation/Handlers/BelongsToHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public function attach( $model, $relationship, $value): void
throw new DomainException('Can`t use BelongsTo relation with multiple select.');
}

$dispatcher = $model->getEventDispatcher();

$model->unsetEventDispatcher();

if(intval($value) > 0)
{
$relationModel = $model->{$relationship}()->getModel();
Expand All @@ -28,7 +32,9 @@ public function attach( $model, $relationship, $value): void
$model->{$relationship}()->dissociate();
}

$model->saveQuietly();
$model->save();

$model->setEventDispatcher($dispatcher);
}

public function retrieve($model, $relationship, $idKey)
Expand Down

0 comments on commit 9c3b36d

Please sign in to comment.