This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi guys, How can a add a list filter, that filters the list item by the given date?
Tried:
created_at_from:
label: Date from
conditions: created_at >= (:filtered)
No success :(
Not sure off the top of my head how to accept an input from the filter, but you could do something like to show all models created in the last week...
Model...
use Carbon\Carbon;
public fuction scopeCreatedDaysAgo($query, $days = 7)
{
return $query->where('created_at', '>=', Carbon::now()->subDays($days));
}
config_filters.yaml...
created_at:
label: Created This Week
type: checkbox
scope: createdDaysAgo
Last updated
Hi Scott, Thanks for the hint!
This way I need to have predefined date ranges, right? Like Today, Yesterday, This Week, This Month, Last Month etc... How can I have a Datepicker on the filters strip and pass the value of it to the Model's scope?
Cheers
I don't believe this is possible through normal list filters. You'll probably need to create a custom partial to include the controls you need and include it in the list view (similarly to how scoreboards are included)
triasrahman said:
any solution for this?
Unfortunately I had to build my own listing controller with my date filters. Just followed UI guide https://octobercms.com/docs/ui/list, works pretty well, looks like default.
1-6 of 6