coolchi/daterangepicker

A simple Date Range filter for Laravel Nova 4.

dev-main 2024-02-15 07:02 UTC

This package is not auto-updated.

Last update: 2024-05-24 06:24:27 UTC


README

A filter for Nova 4 that displays a Date Range Picker instead of a single date picker using Daterangepicker library

Install

Run this command in your nova project: composer require coolchi/daterangepicker

How to use

In your Nova resource, just add DateRangeFilter class in the filters function, and include the column that you would like to use as the one to filter the resource.

 use Coolchi\Daterangepicker\Daterangepicker;

 public function filters(Request $request)
    {
        return [
            new Daterangepicker('created_at'),
        ];
    }

Additionally, you can pass a string with default date range to use in the component. If no value is passed, TODAY value is set as default.

 use Coolchi\Daterangepicker\Daterangepicker;
 use Coolchi\Daterangepicker\DateHelper;

 public function filters(Request $request)
    {
        return [
            new Daterangepicker('created_at', DateHelper::THIS_WEEK),
        ];
    }