Overview
TheDateRangeFilter class provides a date range picker using Flatpickr, allowing users to select a start and end date. It supports custom date formats, min/max date constraints, and custom calendar styling.
Creating a DateRangeFilter
Available Methods
label
format
Sets the date format for display and parsing.Default:
Date format string (PHP date format)
'Y-m-d'minDate
maxDate
calendarClass
key
default
Sets a default date range value for the filter.
The default value (array with ‘from’ and/or ‘to’ keys)
initialValue
Sets an initial date range that is pre-applied when the table first loads.
The initial value (array with ‘from’ and/or ‘to’ keys)
filter
Provides a custom query callback to override the default filter behavior.
A closure that receives
Builder $query and mixed $value (array with ‘from’ and ‘to’ keys) and returns the modified BuildergroupClass / labelClass / inputClass
Sets CSS classes for the filter wrapper, label, or input element.
Value Structure
The filter value is an array withfrom and to keys:
Value Clamping
Date values are automatically clamped to stay within minDate/maxDate bounds and normalized to ‘Y-m-d’ format internally:Default Behavior
By default,DateRangeFilter applies whereDate queries with >= and <=:
Complete Examples
Basic Usage
Pre-applied Date Range
Custom Filter Logic
Usage in Table Component
Date Format Examples
UI Rendering
The filter renders a single input field that opens a Flatpickr calendar in range mode when clicked. Users can select a start and end date, which are displayed in the input field separated by ” to ”.Related Filters
- For single date selection, use DateFilter
- For multiple individual dates, use MultiDateFilter