How to add a filter from a sub relation?
I need to add a filter to the table builder that filters the current incident by district.
A incident has a mm locations() relationship and a location belongs to a district (m to 1).
How can I get the the districts from the locations and filter the incidents?
This doesn't work unfortunately:
Thank you!
7 Replies
If I use a hasManyThrough on my incident model like so:
All Districts get displayed, but if I want to filter by one the follwing exception is thrown:
Column not found: 1054 Unknown column 'locations.location_id' in 'where clause'
You’re relationship is ‘districts’ not ‘district’
yeah, but either way, it doesn't work with the same exception.
Just ideas from the top of my head. I don't use filters much. Hopefully someone else can give you a better answer.
can anyone else help me with this?
My current code is as follows:
Page loads fine, but if I want to filter by district this exception appears:
Thank you! 🙏
Which table are you building? The Location one?
or the incicents?
seems the locations table does not have a location_id
I solved it now with a custom filter: