Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Open
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
22 changes: 20 additions & 2 deletions src/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class DateFilter extends BaseFilter

protected CarbonInterface | string | Closure | null $minDate = null;

protected CarbonInterface | string | Closure | null $defaultFrom = null;

protected CarbonInterface | string | Closure | null $defaultUntil = null;

protected string | Closure | null $displayFormat = 'M j, Y';

protected string | Closure | null $timezone = null;
Expand Down Expand Up @@ -210,6 +214,18 @@ public function timezone(string | Closure | null $timezone): static
return $this;
}

public function defaultFrom(CarbonInterface | string | Closure | null $date): static
{
$this->defaultFrom = $date;
return $this;
}

public function defaultUntil(CarbonInterface | string | Closure | null $date): static
{
$this->defaultUntil = $date;
return $this;
}

public function getFormSchema(): array
{
$schema = $this->evaluate($this->formSchema);
Expand Down Expand Up @@ -243,15 +259,17 @@ public function getFormSchema(): array
->displayFormat($this->displayFormat)
->timezone($this->timezone)
->minDate($this->minDate)
->maxDate(fn($get) => $get('until') ?? $this->maxDate),
->maxDate(fn($get) => $get('until') ?? $this->maxDate)
->default($this->defaultFrom),

Forms\Components\DatePicker::make('until')
->closeOnDateSelection()
->label($this->labels['until'])
->displayFormat($this->displayFormat)
->timezone($this->timezone)
->minDate(fn($get) => $get('from') ?? $this->minDate)
->maxDate($this->maxDate),
->maxDate($this->maxDate)
->default($this->defaultUntil),
])
];
}
Expand Down