Hi octobercms fans,
Is it possible to add pivot data in beforeAttach or attach event?
Something like this:
$model->bindEvent('model.relation.beforeAttach', function ($relationName, $ids, $attr) use ($model){
$new_ids = [];
foreach ($ids as $index => $id) {
$new_ids[$index]['pivot_data'] = $some_data;
}
return $new_ids;
});
As far as I know, its only possible to return true/false to create/not create relation.
Or is there a other way to process data before attaching to belongsToMany
relation.
Thanks