model.relation.beforeDetach

Triggered in October\Rain\Database\Relations\BelongsToMany.

Called before removing a relation between models (only for BelongsToMany relation)

Example usage:

$model->bindEvent('model.relation.beforeDetach', function (string $relationName, ?array $parsedIds) use (\October\Rain\Database\Model $model) {
    foreach ((array) $parsedIds as $id) {
        if (!$model->isRelationValid($parsedIds)) {
            return false;
        }
    }
});