Closed alexmanase closed 12 months ago
@alexmanase if you change the method from query()
to baseQuery()
you will get the desired result as shown in the documentation https://filamentphp.com/docs/3.x/tables/filters#modifying-the-base-query.
The final result will then be:
Filter::make('is_unique')
->baseQuery(fn (Builder $query): Builder => $query->groupBy('name')),
It works. Thank you!
Package
filament/filament
Package Version
v3.0.53
Laravel Version
v10.24.0
Livewire Version
v3.0.5
PHP Version
PHP 8.2.8
Problem description
I tried to create a filter that returns unique values for a query, like this:
Expected behavior
It has to correctly run the query from the Filter. When I run it in Tinker, it worked:
In the reproduction repository it should return 3 results, but instead it returns all of them.
Steps to reproduce
README.md
Reproduction repository
https://github.com/alexmanase/filament-filter-for-distinct-results-issue
Relevant log output
No response