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

Copyright © 2024 Winter CMS