model.relation.beforeRemove

Called before removing a relation to the model (for AttachOneOrMany, HasOneOrMany & MorphOneOrMany relations)

Example usage:

$model->bindEvent('model.relation.beforeRemove', function (string $relationName, \Winter\Storm\Database\Model $relatedModel) use (\Winter\Storm\Database\Model $model) { if ($relationName === 'permanentRelation') { throw new \Exception("Cannot dissociate a permanent relation!"); } });

Usage

Triggers

Copyright © 2024 Winter CMS