### Install Filament Header Filters Source: https://github.com/leek/filament-header-filters/blob/main/README.md Install the package using Composer. This command adds the necessary files to your project. ```bash composer require leek/filament-header-filters ``` -------------------------------- ### Run Tests with Composer Source: https://github.com/leek/filament-header-filters/blob/main/README.md Execute the project's test suite using Composer. Ensure Composer is installed and dependencies are managed. ```bash composer test ``` -------------------------------- ### Build App Assets Source: https://github.com/leek/filament-header-filters/blob/main/README.md After adding the stylesheet, rebuild your application's assets. If using Vite locally, restart or keep the development server running. ```bash npm run build ``` ```bash npm run dev ``` -------------------------------- ### Implement Dropdown Header Filter Source: https://github.com/leek/filament-header-filters/blob/main/README.md Use `SelectFilter` for exact-match filtering on a column. Configure options using an Enum or an array. The default placeholder is 'All'. ```php use App\Enums\OrderStatus; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\SelectFilter; TextColumn::make('status') ->badge() ->headerFilter( SelectFilter::make('status') ->options(OrderStatus::class) ->native(false) ) ``` -------------------------------- ### Publish Filacheck Configuration Source: https://github.com/leek/filament-header-filters/blob/main/README.md This command publishes the configuration file for FilaCheck, allowing you to customize its rules. This is useful for disabling specific rules that may cause false positives with header filters. ```bash php artisan vendor:publish --tag=filacheck-config ``` -------------------------------- ### Include Package Stylesheet Source: https://github.com/leek/filament-header-filters/blob/main/README.md Add the package stylesheet to your panel theme's Vite configuration. Ensure it's placed after Filament's theme import to correctly override styles. ```css @import '../../../../vendor/filament/filament/resources/css/theme.css'; @import '../../../../vendor/leek/filament-header-filters/resources/css/filament-header-filters.css'; ``` -------------------------------- ### Implement Min/Max Range Header Filter Source: https://github.com/leek/filament-header-filters/blob/main/README.md Create a custom `Filter` with two `TextInput` fields for numeric range filtering. Use `->columns(2)` for a side-by-side layout and define the query logic to apply the min and max values. ```php use Filament\Forms\Components\TextInput; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Filter; use Illuminate\Database\Eloquent\Builder; TextColumn::make('total_price') ->headerFilter( Filter::make('total_price_range') ->columns(2) ->schema([ TextInput::make('min')->numeric()->placeholder('Min'), TextInput::make('max')->numeric()->placeholder('Max'), ]) ->query(fn (Builder $query, array $data): Builder => $query ->when($data['min'] ?? null, fn (Builder $q, $v): Builder => $q->where('total_price', '>=', $v)) ->when($data['max'] ?? null, fn (Builder $q, $v): Builder => $q->where('total_price', '<=', $v)) ) ) ``` -------------------------------- ### Implement Date Range Header Filter Source: https://github.com/leek/filament-header-filters/blob/main/README.md Utilize `DatePicker` components within a custom `Filter` to enable filtering by a date range. Configure the schema with 'from' and 'until' fields and define the query to filter records based on the selected dates. ```php use Filament\Forms\Components\DatePicker; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Filters\Filter; use Illuminate\Database\Eloquent\Builder; TextColumn::make('created_at') ->label('Order date') ->date() ->headerFilter( Filter::make('order_date_range') ->columns(2) ->schema([ DatePicker::make('from')->placeholder('From')->native(false), DatePicker::make('until')->placeholder('Until')->native(false), ]) ->query(fn (Builder $query, array $data): Builder => $query ->when($data['from'] ?? null, fn (Builder $q, $v): Builder => $q->whereDate('created_at', '>=', $v)) ->when($data['until'] ?? null, fn (Builder $q, $v): Builder => $q->whereDate('created_at', '<=', $v)) ) ) ``` -------------------------------- ### Add HasHeaderFilters Trait to Livewire Component Source: https://github.com/leek/filament-header-filters/blob/main/README.md Include the `HasHeaderFilters` trait in your Livewire component that utilizes `InteractsWithTable`. This enables the header filtering functionality. ```php use Filament\Resources\Pages\ListRecords; use Leek\FilamentHeaderFilters\Concerns\HasHeaderFilters; class ListOrders extends ListRecords { use HasHeaderFilters; } ``` -------------------------------- ### Hide Filters Button with Only Header Filters Source: https://github.com/leek/filament-header-filters/blob/main/README.md When a table exclusively uses header filters and has no panel filters, this setting hides the empty filters dropdown button. This ensures a cleaner UI by not rendering an unnecessary button. ```php use Filament\Tables\Enums\FiltersLayout; public function table(Table $table): Table { return $table ->filtersLayout(FiltersLayout::Hidden) ->columns([ TextColumn::make('status')->headerFilter(/* ... */), // ... ]); } ``` -------------------------------- ### Disable Missing Table Filters Rule in Filacheck Source: https://github.com/leek/filament-header-filters/blob/main/README.md This configuration snippet disables the 'missing-table-filters' rule within FilaCheck. This prevents the rule from incorrectly flagging tables that only utilize header filters. ```php // config/filacheck.php 'missing-table-filters' => [ 'enabled' => false, ], ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.