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

[9.x] Extract child route model relationship name into a method #43597

Merged
merged 3 commits into from Aug 8, 2022

Conversation

orkhanahmadov
Copy link
Contributor

@orkhanahmadov orkhanahmadov commented Aug 8, 2022

This small change extracts the child route model relationship name into a dedicated protected method.

The previous approach always assumes that the plural name of the relationship is going to be used for the relationship. But this is not always the case, if the parent is using the hasOne relationship, usually the method name for this relationship is in a singular form, not plural. But the previous approach always tries to resolve it as plural.

Having a dedicated method for child route relationship name makes it possible to conditionally provide different relationship name depending on $childType.

@orkhanahmadov orkhanahmadov changed the title Extract child route model relationship name into a method [9.x] Extract child route model relationship name into a method Aug 8, 2022
@taylorotwell taylorotwell merged commit 3ccf1b1 into laravel:9.x Aug 8, 2022
16 checks passed
Ken-vdE pushed a commit to Ken-vdE/framework that referenced this pull request Aug 9, 2022
…vel#43597)

* Extract child route model relationship name

* Fix style

* Update Model.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
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