diff --git a/docs/filter-types/filters-date.md b/docs/filter-types/filters-date.md index d29a900df..7880c6087 100644 --- a/docs/filter-types/filters-date.md +++ b/docs/filter-types/filters-date.md @@ -33,6 +33,7 @@ public function filters(): array } ``` +## setFilterDefaultValue Date filters also support the setFilterDefaultValue() method, which must be a valid date in the "Y-m-d" format. This will apply as a default until removed. ```php public function filters(): array @@ -47,5 +48,22 @@ public function filters(): array ]; } ``` - + +## setPillsLocale +Date Filters also support the setPillsLocale method, which allows you to set a locale for use in generating the Filter Pills values +```php +public function filters(): array +{ + return [ + DateFilter::make('Verified From') + ->setPillsLocale('fr ') // Use French localisation for the Filter Pills values + ->config([ + 'min' => '2020-01-01', // Earliest Acceptable Date + 'max' => '2021-12-31', // Latest Acceptable Date + 'pillFormat' => 'd M Y', // Format for use in Filter Pills + 'placeholder' => 'Enter Date', // A placeholder value + ]) + ]; +} +``` diff --git a/docs/filter-types/filters-daterange.md b/docs/filter-types/filters-daterange.md index a376b3cf4..5e340b157 100644 --- a/docs/filter-types/filters-daterange.md +++ b/docs/filter-types/filters-daterange.md @@ -85,6 +85,34 @@ or ->setFilterDefaultValue(['2024-05-05', '2024-06-06']) ``` +## setPillsLocale +DateRange Filters also support the setPillsLocale method, which allows you to set a locale for use in generating the Filter Pills values +```php +public function filters(): array +{ + return [ + DateRangeFilter::make('EMail Verified Range') + ->setPillsLocale('fr ') // Use French localisation for the Filter Pills values + ->config([ + 'allowInput' => true, // Allow manual input of dates + 'altFormat' => 'F j, Y', // Date format that will be displayed once selected + 'ariaDateFormat' => 'F j, Y', // An aria-friendly date format + 'dateFormat' => 'Y-m-d', // Date format that will be received by the filter + 'earliestDate' => '2020-01-01', // The earliest acceptable date + 'latestDate' => '2023-08-01', // The latest acceptable date + 'placeholder' => 'Enter Date Range', // A placeholder value + 'locale' => 'en', + ]) + ->setFilterPillValues([0 => 'minDate', 1 => 'maxDate']) // The values that will be displayed for the Min/Max Date Values + ->filter(function (Builder $builder, array $dateRange) { // Expects an array. + $builder + ->whereDate('users.email_verified_at', '>=', $dateRange['minDate']) // minDate is the start date selected + ->whereDate('users.email_verified_at', '<=', $dateRange['maxDate']); // maxDate is the end date selected + }), + ]; +} +``` + ## Configuration By default, this filter will inject the Flatpickr JS Library and CSS. However, you can customise this behaviour using the configuration file. diff --git a/docs/filter-types/filters-datetime.md b/docs/filter-types/filters-datetime.md index 64c14eca4..eafc19bca 100644 --- a/docs/filter-types/filters-datetime.md +++ b/docs/filter-types/filters-datetime.md @@ -33,6 +33,7 @@ public function filters(): array } ``` +## setFilterDefaultValue DateTime filters also support the setFilterDefaultValue() method, which must be a valid datetime in the "Y-m-dTH:i" format. This will apply as a default until removed. ```php public function filters(): array @@ -47,6 +48,23 @@ public function filters(): array ->setFilterDefaultValue('2023-07-07T06:27') ]; } +``` + +## setPillsLocale +DateTime Filters also support the setPillsLocale method, which allows you to set a locale for use in generating the Filter Pills values +```php +public function filters(): array +{ + return [ + DateTimeFilter::make('Verified From') + ->setPillsLocale('fr ') // Use French localisation for the Filter Pills values + ->config([ + 'min' => '2020-01-01', // Earliest Acceptable Date + 'max' => '2021-12-31', // Latest Acceptable Date + 'pillFormat' => 'd M Y - H:i', // Format for use in Filter Pills + 'placeholder' => 'Enter Date', // A placeholder value + ]) + ]; +} ``` -