Calendar instead of input field in "dateTime" searchable as individual columns.
Hi,
Having:
->searchable(isIndividual: true) gives us a searching input field.
Does anyone know if it is possible to have instead a calendar to select the dates?
Thanks.
1 Reply
HI. I solve it using a Filter:
->filters([
Tables\Filters\TernaryFilter::make('activado'),
Tables\Filters\Filter::make('created_at')
->form([
Forms\Components\DatePicker::make('creado_desde'),
Forms\Components\DatePicker::make('creado_hasta')->default(now()),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['creado_desde'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date),
)
->when(
$data['creado_hasta'],
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date),
);
})
])
Hope it helps
In my case format is for Spain, so change that, and field names, and I think you got it.