model.relation.beforeAttach
        
        Called before creating a new relation between models (only for BelongsToMany relation)
    
    
Example usage:
$model->bindEvent('model.relation.beforeAttach', function (string $relationName, array $attachedIdList, array $insertData) use (\Winter\Storm\Database\Model $model) {
    if (!$model->isRelationValid($attachedIdList)) {
        throw new \Exception("Invalid relation!");
        return false;
    }
});
NOTE: If a custom pivotModel is being used the parameters will actually be
string $relationName, mixed $id, array $attributes
Usage
Triggers
| Class or file | Line | 
|---|---|
| Winter\Storm\Database\Relations\Concerns\BelongsOrMorphsToMany | 148 | 
    Copyright © 2025 Winter CMS