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

Copyright © 2024 Winter CMS