LaravelPackages.net
Acme Inc.
Toggle sidebar
edeoliv/filament-datefilter

Date filter component for filament tables.

3
0
1.0.0
About edeoliv/filament-datefilter

edeoliv/filament-datefilter is a Laravel package for date filter component for filament tables.. It currently has 0 GitHub stars and 3 downloads on Packagist (latest version 1.0.0). Install it with composer require edeoliv/filament-datefilter. Discover more Laravel packages by edeoliv or browse all Laravel packages to compare alternatives.

Last updated

Filament Date Filter

A easy-to-use date filter with range option for Laravel Filament.

Installation

Install the package via composer (requires filament >= 2.15)

composer require edeoliv/filament-datefilter

Usage

Date filters allow you to quickly create a filter that allows the user to select a date.

use Edeoliv\FilamentDateFilter\DateFilter;

DateFilter::make('created_at')
    ->label(__('Created At'))
    ->minDate(Carbon::today()->subMonth(1))
    ->maxDate(Carbon::today()->addMonth(1))
    ->timeZone('America/New_York')

Another common use case is to filter by a date range. You can do this with range() method:

use Edeoliv\FilamentDateFilter\DateFilter;

DateFilter::make('created_at')
    ->label(__('Created At'))
    ->minDate(Carbon::today()->subMonth(1))
    ->maxDate(Carbon::today()->addMonth(1))
    ->timeZone('America/New_York')
    ->range()
    ->fromLabel(__('From'))
    ->untilLabel(__('Until'))

If you need to use a different column name than the one you pass to the make() method, you can use the useColumn() method:

use Edeoliv\FilamentDateFilter\DateFilter;

DateFilter::make('created_at')
    ->useColumn('updated_at')

Global Configuration

You can set From/Until label globally using configureUsing() method in a service provider:

use Edeoliv\FilamentDateFilter\DateFilter;

DateFilter::configureUsing(fn ($filter) => $filter->fromLabel(__('From'))->untilLabel(__('Until')));

Credits

Comments