model.relation.beforeAdd

Called before adding a relation to the model (for AttachOneOrMany, HasOneOrMany & MorphOneOrMany relations)

Example usage:

$model->bindEvent('model.relation.beforeAdd', 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