Filters should be grouped by key instead of class name
Closed this issue · 4 comments
The HasDetachedFilters trait groups the filters by the filter class property which is defined in the modifyFilters method:
$filter->class = get_class($filter);
In this case when we use on a resource a filter multiple times (for example with different parameters) it's not working.
I suggest to use the filter key instead of the class name because that is unique. It could be done by only one line change:
$filter->class = $filter->key();
By the way nice work and thanks for the package!
public function key()
{
return get_class($this);
}
Doesn't the ->key()
do exact same thing?
In base filters, yes. But in generic filters which you can resuse multiple times on a resource, you have to override it to be unique.
As the documentation also suggests: https://nova.laravel.com/docs/3.0/filters/defining-filters.html#dynamic-filters
You're right, forgot that was a thing.
I released version 1.0.10 which fixes this issue.
Thank you and good luck!
Thank you again for your work, best regards.