Add custom query to a filter
When I set a filter like in the example above my table always filtered and showed only one record with ID 1. I didn't apply the filter and the query string is empty.
I want to add a custom query to a filter. How to achieve this?
Solution:Jump to solution
query
exists for the other filters like Filter and TernaryFilter. With SelectFilter, the query is handled internally for you so it acts a little differently.5 Replies
What are you trying to accomplish? If you just need to filter one option, then use a normal Filter and not a Select Filter. A SelectFilter should be used for multiple options.
So if you just want to filter where
causer_id == 1
, then you could do:
This is just a simple example. I have a more complex logic but I want to show that
$query->where('causer_id', 1)
always applies to a whole tableOk…so does using
Filter::make()…
work for you?Yes, it works. But I'm not sure for what purpose
->query()
exists. Am I not using it right?Solution
query
exists for the other filters like Filter and TernaryFilter. With SelectFilter, the query is handled internally for you so it acts a little differently.