Invalid SQL Generated when using Relation Manager
Hi folks, I was interested to explore this. I issued this command
and then registered the relation. When I execute the app I am getting this SQL being generated:
It should read like this
I cannot see where it's looking when generating the SQL that could result in it determining that there is a column called
Anyone able to help?
thx
J
Solution:Jump to solution
It's probably or in the other order:
```php
public function my_property_rooms()
{...
10 Replies
Oh here is a link to the Flare - https://flareapp.io/share/o7AQBJv7
Flare
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'my_property_rooms.my_property_my_property_id' in 'where clause' (Connection: mysql, SQL: select count(*) as aggregate from
my_property_rooms
where my_property_rooms
.my_property_my_property_id
= 6 and my_property_rooms
.my_property_my_property_id
is not null) - The error occurred at...Can you share the relationship? And the relation manager?
The relationship is my_properties (parent - primary key is ) and the child is my_property_rooms (primary key is and has an FK to my_properties - in MySQL terms it is defined as
The relation manager is defined as:
I mean the relationship definition on your Model
Entire MyProperty model:
I guess the issue is that you don't follow Laravel conventions but rely on them.
This part assumes you are following Laravle conventions. You need to pass your keys as second and maybe third param.
Ah OK - the db design & naming conventions didn't explicitly align with any conventions (no tool specifically in mind at the time). As a newbie also to Laravel and PHP I'm finding my feet still.
Where would I be passing these keys - within the "relation manager"?
No, this is totally unrelated to Filament. It's about your Laravel relationships.
Solution
It's probably or in the other order:
Thanks Dennis, I have this working now - really do appreciate your guidance on that & appreciate that it's core Laravel knowledge I'm missing (which I fully understand is itself a prereq to using Filament effectively).
cheers,
j