Date Filter
DateFilter renders a date picker in the UI and automatically applies the correct timestamp querying logic to your database.
Basic Usage
Section titled “Basic Usage”By default, the DateFilter acts as a single-date selector. It comes with three default operators:
equals(Exact date)<(Before this date)>(After this date)
use Kinetics\Filters\DateFilter;
DateFilter::make('created_at')Date Range Selection
Section titled “Date Range Selection”Instead of picking a single date, you can configure the filter to accept a Start Date and an End Date.
To enable this, call the range() method.
use Kinetics\Filters\DateFilter;
DateFilter::make('created_at')->range()When range() is enabled:
- The frontend UI transforms into a dual date-picker (start and end).
- The available operator is forcefully set to
between. - The SQL query generated will use the
WHERE ... BETWEENlogic.
API Reference
Section titled “API Reference”| Method | Description |
|---|---|
make(string $key) | Creates a new filter instance. |
label(string $label) | Sets the filter label. |
column(string $column) | Specifies the database column name if different from the key. |
relation(string $relation, string $relationKey) | Explicitly sets the relationship to query. |
operators(array $operators) | Overrides the allowed operators for this filter. |
range(bool $condition = true) | Sets this filter to act purely as a date range filter (from-to). |