From 413b192a2067080a42ada7c1a1b3810d601d9e9d Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Wed, 27 Jul 2022 17:05:12 -0400 Subject: [PATCH] add relatedModel to dissociate events --- src/Database/Relations/Concerns/BelongsOrMorphsTo.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Database/Relations/Concerns/BelongsOrMorphsTo.php b/src/Database/Relations/Concerns/BelongsOrMorphsTo.php index 8c51f88ed..0a1033df1 100644 --- a/src/Database/Relations/Concerns/BelongsOrMorphsTo.php +++ b/src/Database/Relations/Concerns/BelongsOrMorphsTo.php @@ -58,14 +58,14 @@ public function dissociate() * * Example usage: * - * $model->bindEvent('model.relation.beforeDissociate', function (string $relationName) use (\Winter\Storm\Database\Model $model) { + * $model->bindEvent('model.relation.beforeDissociate', function (string $relationName, Model $relatedModel) { * if ($relationName === 'permanentRelation') { * throw new \Exception("Cannot dissociate a permanent relation!"); * } * }); * */ - $this->parent->fireEvent('model.relation.beforeDissociate', [$this->relationName]); + $this->parent->fireEvent('model.relation.beforeDissociate', [$this->relationName, $this->getRelated()]); $result = parent::dissociate(); @@ -75,13 +75,13 @@ public function dissociate() * * Example usage: * - * $model->bindEvent('model.relation.afterDissociate', function (string $relationName) use (\Winter\Storm\Database\Model $model) { + * $model->bindEvent('model.relation.afterDissociate', function (string $relationName, Model $relatedModel) use (\Winter\Storm\Database\Model $model) { * $modelClass = get_class($model); * traceLog("{$relationName} was dissociated from {$modelClass}."); * }); * */ - $this->parent->fireEvent('model.relation.afterDissociate', [$this->relationName]); + $this->parent->fireEvent('model.relation.afterDissociate', [$this->relationName, $this->getRelated()]); return $result; }