Date range filter? #604
-
I want to implement date filtering but i really can't wrap my head around it unfortunally. I saw an example in the documentation of the filter itself but didn't find an example on how to write the query for the builder. This is the exaple i found: 'date' => Filter::make('Date')
->date([
'min' => now()->subYear()->format('Y-m-d'), // Optional
'max' => now()->format('Y-m-d') // Optional
]), And this is what's inside my query function: return Order::query()->with('store')
->when($this->getFilter('date'), fn ($query, $start_date, $end_date) => $query->whereBetween('orders.created_at', [$start_date, $end_date])); As you can imagine that doesn't work, in the filter dropdown i see only one date selector (no Somebody can provide me an easy to understand example or a simple explanation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
They are two different filters:
https://gist.github.com/rappasoft/948adf542307b8f620d53c7c7e735d3c#file-laravel-livewire-tables-demo-table-php-L99
https://gist.github.com/rappasoft/948adf542307b8f620d53c7c7e735d3c#file-laravel-livewire-tables-demo-table-php-L117