model.relation.beforeDetach
Called before removing a relation between models (only for BelongsToMany relation)
Example usage:
$model->bindEvent('model.relation.beforeDetach', function (string $relationName, array $attachedIdList) use (\Winter\Storm\Database\Model $model) { if (!$model->isRelationValid($attachedIdList)) { throw new \Exception("Invalid relation!"); return false; } });
Usage
Triggers
Class or file | Line |
---|---|
Winter\Storm\Database\Relations\Concerns\BelongsOrMorphsToMany
|
209 |
Copyright © 2024 Winter CMS