Advanced Tables Filter Not Adding Filter

What I'm trying to do: Hello, this is a very simple table, I'm trying to add an Advanced Table Filter for "created_at". Thank you in advance, maybe I'm doing something wrong, maybe something is wrong with the package? What I did: I added a simple filter to the table My Issue/The error: My filter is be removed (and not shown on in the filter menu) by the following code: Archilex\AdvancedTables\Filters method getCollectedFilters on line 110 using version 3.7.27 of package archilex/filament-filter-sets The line in question is removing all filters where it's an instance of AdvancedFilter (which makes no sense)
->reject(function (BaseFilter $filter) {
return $this->isColumnFilter($filter);
})

protected function isColumnFilter($filter): bool
{
return
$filter instanceof TextFilter ||
$filter instanceof NumericFilter ||
$filter instanceof DateFilter ||
$filter instanceof SelectFilter;
}
->reject(function (BaseFilter $filter) {
return $this->isColumnFilter($filter);
})

protected function isColumnFilter($filter): bool
{
return
$filter instanceof TextFilter ||
$filter instanceof NumericFilter ||
$filter instanceof DateFilter ||
$filter instanceof SelectFilter;
}
My Code:
->filters([
AdvancedFilter::make()
->filters([
DateFilter::make('created_at'),
])
])
->columns([
// ...
TextColumn::make('created_at')
->dateTime('m/d/Y h:i A')
->label('Date')
->timezone(auth()->user()->timezone)
->sortable(),
])
->filters([
AdvancedFilter::make()
->filters([
DateFilter::make('created_at'),
])
])
->columns([
// ...
TextColumn::make('created_at')
->dateTime('m/d/Y h:i A')
->label('Date')
->timezone(auth()->user()->timezone)
->sortable(),
])
Solution:
This was already discussed offline earlier today, but since I’m just now seeing this was posted here too I’ll respond here too: The issue you are having is the DateFilter is what I call a “columnFilter” this means you need to use the ->includeColumns() method on your filter. So to break it down:...
Jump to solution
2 Replies
Solution
Kenneth Sese
Kenneth Sese5w ago
This was already discussed offline earlier today, but since I’m just now seeing this was posted here too I’ll respond here too: The issue you are having is the DateFilter is what I call a “columnFilter” this means you need to use the ->includeColumns() method on your filter. So to break it down: If you want to autogenerate your filters based on your table columns (including ‘created_at’) then all you need is:
AdvancedFilter::make()
->includeColumns() // you are missing this.
AdvancedFilter::make()
->includeColumns() // you are missing this.
If you just want the DateFilter for created at then you can pass that into the ->includeColumns() method:
AdvancedFilter::make()
->includeColumns([
'created_at'
]);
AdvancedFilter::make()
->includeColumns([
'created_at'
]);
You only need to use the ->filters() method if you want to a) don’t want to autogenerate filters (which also means you can’t use column filters), b) you want to override a column filter, or c) if you want to include a custom filter (ie filter data on your table where you don’t have a column for it) Hope that helps! p.s. please use the advanced-tables channel and feel free to tag me so I get notified.
SokarNox
SokarNoxOP5w ago
Thanks for the help!
Want results from more Discord servers?
Add your server