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

[6.x] Implemented parse ID on find method for many to many relation #30359

Merged
merged 1 commit into from
Oct 21, 2019
Merged

[6.x] Implemented parse ID on find method for many to many relation #30359

merged 1 commit into from
Oct 21, 2019

Conversation

pauladams8
Copy link
Contributor

I implemented the parseId() on the find() method for the BelongsToMany trait, meaning that a related model can be found using either a primary key, or an existing model instance.

Example: $project->users()->find($user); can be used as well as $project->users()->find($user->id);.

This is useful looking up pivot table data for two existing model instances: $project->users->find($user)->pivot->role;.

I think this is more consistent with other methods in the BelongsToMany trait, such as updateExistingPivot(), which implements parseId() meaning a model instance or ID can be passed.

@pauladams8 pauladams8 changed the title Implemented parse ID for find method on many to many relation Implemented parse ID on find method for many to many relation Oct 20, 2019
@pauladams8 pauladams8 changed the title Implemented parse ID on find method for many to many relation [6.x] Implemented parse ID on find method for many to many relation Oct 20, 2019
@taylorotwell taylorotwell merged commit e6327e6 into laravel:6.x Oct 21, 2019
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.

None yet

2 participants