model.relation.beforeAssociate
Called before associating a relation to the model (only for BelongsTo/MorphTo relations)
Example usage:
$model->bindEvent('model.relation.beforeAssociate', function (string $relationName, \Winter\Storm\Database\Model $relatedModel) use (\Winter\Storm\Database\Model $model) { if ($relationName === 'dummyRelation') { throw new \Exception("Invalid relation!"); } });
Usage
Triggers
Class or file | Line |
---|---|
Winter\Storm\Database\Relations\Concerns\BelongsOrMorphsTo
|
25 |
Copyright © 2024 Winter CMS