model.relation.afterAdd

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

Example usage:

$model->bindEvent('model.relation.afterAdd', function (string $relationName, \Winter\Storm\Database\Model $relatedModel) use (\Winter\Storm\Database\Model $model) { $relatedClass = get_class($relatedModel); $modelClass = get_class($model); traceLog("{$relatedClass} was added as {$relationName} to {$modelClass}."); });

Usage

Globally

use Event;

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

Triggers

Copyright © 2023 Winter CMS