-
-
Notifications
You must be signed in to change notification settings - Fork 900
[Laravel] BelongsTo Link is not working #6930
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
Labels
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
soyuka
added a commit
to soyuka/core
that referenced
this issue
Apr 10, 2025
soyuka
added a commit
to soyuka/core
that referenced
this issue
Apr 10, 2025
soyuka
added a commit
that referenced
this issue
Apr 10, 2025
soyuka
added a commit
to soyuka/core
that referenced
this issue
Apr 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
API Platform version(s) affected: 4.0.16
Description
When creating a SubResource for a HasMany Realation on a Model Link Fails.
How to reproduce
Possible Solution
Having 2 Models:
GrandFather
GrandSon
Created Using Following Migrations:
GrandFather:
GrandSon:
Creates 2 Endpoints:
/api/grand_fathers/{id_grand_father}/grand_sons
Calling:
Works Properly and returns all GrandSons belonging to GrandFather with id_grand_father =
{id_grand_father}
/api/grand_sons/{id_grand_son}/grand_father
Carlling:
Returns Error:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'grand_sons.grand_father_id' in 'where clause' (Connection: mysql, SQL: select * from `grand_fathers` where `grand_sons`.`grand_father_id` = 1 limit 1)"`
As you can see, the query is missformed.
Possible Solution
I think commit 5818e80 fixed BelongsToMany Relation but still is not manageing BelongsTo Relations.
My suggestion is adding the following code after managing BelonsToMany Relations here
EDIT
The correct code should be:
The text was updated successfully, but these errors were encountered: