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

Globally

use Event;

Event::listen('model.relation.beforeAssociate', function () {
    // Your event listener code goes here...
});

Triggers

Copyright © 2024 Winter CMS