Calendar instead of input field in "dateTime" searchable as individual columns.

Hi, Having:
Tables\Columns\TextColumn::make('updated_at')
->dateTime('M j, Y H:i')
->description(fn (Model $record): string => $record->updated_at->since())
->searchable(isIndividual: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime('M j, Y H:i')
->description(fn (Model $record): string => $record->updated_at->since())
->searchable(isIndividual: true),
->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
Albert Lens
Albert Lens16mo ago
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.
Want results from more Discord servers?
Add your server