Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
N

Date Range Filter

Readme

Date Range Filter for Laravel Nova

Nova filter that displays a Date Range Picker instead of a select.

Install

Run this command in your nova project: composer require ampeco/nova-date-range-filter

How to use

Just use DateRangeFilter class instead of Filter

use Ampeco\Filters\DateRangeFilter;

class DateRange extends DateRangeFilter
{
    public function apply(Request $request, $query, $value)
    {
        $from = Carbon::parse($value[0])->startOfDay();
        $to = Carbon::parse($value[1])->endOfDay();

        return $query->whereBetween('created_at', [$from, $to]);
    }

    /**
     * Get the filter's available options.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    // public function options(Request $request)
    // {
    //     return [
    //         'firstDayOfWeek' => 0,
    //         'separator' => '-',
    //         'enableTime' => false,
    //         'enableSeconds' => false,
    //         'twelveHourTime' => false
    //     ];
    // }
}

Customization

Use fluent interface to configure your DateRange filter

(new DateRange)->placeholder("Placeholder")->dateFormat("m d Y")

Screenshots

Reviews

By denisvasilievclarity on August 23, 2023

Doesn't work.

By echocage123 on March 12, 2023

Unable to select date interval

By Jose Erick Carreon on September 24, 2022

This doesn't work if you don't add " 'mode' => 'range', " to options.

By osama on August 4, 2022

good filter

By Tim on May 12, 2022

For the people trying to use this. It defaults to single mode. So add 'mode' => 'range' to your options method in the filter.

By Geert Lucas on March 8, 2022

Does not work. Selecting ranges not possible

By Mira Thakkar on January 27, 2022

It is not working in the way of not able to select two dates. Can you please provide proper solution or documentation of that

By Valeriu Vodnicear on November 12, 2021

interval can't be selected

Back to Top
Added 6 years ago
Last updated 4 Years Ago
Version 0.1.3
Composer
ampeco/nova-date-range-filter
GitHub stars 35
Packagist downloads 971,728

Favorites

36 users favorited

Rating

2.90
(out of 5)
★★★★★
★★★★
★★★
★★
13 ratings

Author

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas