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

Triggers

Copyright © 2024 Winter CMS