Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Eloquent not firing custom pivot models creation events on attachment to parent. #10435

Closed
olsgreen opened this issue Oct 1, 2015 · 1 comment

Comments

@olsgreen
Copy link
Contributor

olsgreen commented Oct 1, 2015

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...

Same issue here #8452.

@olsgreen 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
@olsgreen
Copy link
Contributor Author

Closing issue dealt with here #10545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant