model.relation.beforeDissociate

Called before dissociating a relation to the model (only for BelongsTo/MorphTo relations)

Example usage:

$model->bindEvent('model.relation.beforeDissociate', function (string $relationName, Model $relatedModel) { if ($relationName === 'permanentRelation') { throw new \Exception("Cannot dissociate a permanent relation!"); } });

Usage

Globally

use Event;

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

Triggers

Copyright © 2024 Winter CMS