Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for setPillsLocale #1800

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion docs/filter-types/filters-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
])
];
}
```

28 changes: 28 additions & 0 deletions docs/filter-types/filters-daterange.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
20 changes: 19 additions & 1 deletion docs/filter-types/filters-datetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
])
];
}
```


Loading