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

[8.x] Add morph type to attributes when making new pivot #36640

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

jasonlewis
Copy link
Contributor

Currently when attaching a morph pivot the type will be set on the new pivot record as it's done within the overloaded baseAttachRecord method.

When making a new pivot it's handy to set the morph type as the pivot is ambiguous without it. My main use case is a deleting event on my custom morph pivot model. This event at the moment will only get the IDs for the pivot but not the morph type, so I don't exactly know what is being deleted.

If there's potentially problems elsewhere with setting this here then that's fine, it can be worked around for my cases, I just figured it'd be nice to get this in upstream.

Cheers.

@driesvints
Copy link
Member

@jasonlewis Jason! 👋 It's been forever :D

@GrahamCampbell GrahamCampbell changed the title [8.x] Add morph type to attributes when making new pivot. [8.x] Add morph type to attributes when making new pivot Mar 18, 2021
@taylorotwell taylorotwell merged commit 66ad9cd into laravel:8.x Mar 18, 2021
@taylorotwell
Copy link
Member

Hey Jason ❤️

So - I added a getMorphType method on the MorphPivot class for you. That should let you get to it without us having to worry about this potentially being a breaking change.

@jasonlewis
Copy link
Contributor Author

Thanks fellas, hope to see you around! 😄

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

Successfully merging this pull request may close these issues.

3 participants