outl1ne / nova-detached-filters

This Laravel Nova package allows you to detach filters from the filter dropdown and show them on a card
MIT License
61 stars 21 forks source link

Filters should be grouped by key instead of class name #13

Closed easyFloyd closed 4 years ago

easyFloyd commented 4 years ago

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!

KasparRosin commented 4 years ago
public function key()
{
    return get_class($this);
}

Doesn't the ->key() do exact same thing?

easyFloyd commented 4 years ago

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

KasparRosin commented 4 years ago

You're right, forgot that was a thing. I released version 1.0.10 which fixes this issue. Thank you and good luck!

easyFloyd commented 4 years ago

Thank you again for your work, best regards.