You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a custom pivot model setup in a ChildModel as such:
class ChildModel extends Model
{
...
public function newPivot(Model $parent, array $attributes, $table, $exists)
{
return new CustomPivotModel($parent, $attributes, $table, $exists);
}
...
}
When I attach a child through the parents relationship, $parent->relationship()->attach($child), the pivot models creating event is never fired as the pivot record is committed straight to the DB here.
I'm guessing this is a bug? Would a pull fixing this be considered? Spinning up a new instance of the pivot model and then firing the events, collecting the attributes and saving to the DB would work but is not ideal. Or just filling the model and calling save but that would bypass all of the query pipework within BelongsToMany, food for thought...
The text was updated successfully, but these errors were encountered:
olsgreen
changed the title
Eloquent not firing custom pivot models creation events on attachment to parent.
[5.1] Eloquent not firing custom pivot models creation events on attachment to parent.
Oct 1, 2015
I have a custom pivot model setup in a
ChildModel
as such:When I attach a child through the parents relationship,
$parent->relationship()->attach($child)
, the pivot models creating event is never fired as the pivot record is committed straight to the DB here.I'm guessing this is a bug? Would a pull fixing this be considered?
Spinning up a new instance of the pivot model and then firing the events, collecting the attributes and saving to the DB would work but is not ideal.Or just filling the model and calling save but that would bypass all of the query pipework withinBelongsToMany
, food for thought...Same issue here #8452.
The text was updated successfully, but these errors were encountered: