digital-creative / nova-range-input-filter

A Laravel Nova range input filter.

Stars
3

Nova Range Input Filter

Latest Version on Packagist
Total Downloads
License

A Laravel Nova range input filter.

RangeInputFilter in Action

Installation

You can install the package via composer:

composer require digital-creative/nova-range-input-filter

Basic Usage

Create a filter as usual and extend the DigitalCreative\RangeInputFilter\RangeInputFilter class

use DigitalCreative\RangeInputFilter\RangeInputFilter;

class MyFilter extends RangeInputFilter {

    public function apply(Request $request, $query, $value)
    {
        // $value will always be [ "from" => ?, "to" => ? ]
    }
    
    public function options(Request $request)
    {
        return [
            'fromPlaceholder' => 0,
            'toPlaceholder' => 20,
            'dividerLabel' => 'to',
        ];
    }

}

and use it as usual on the filters methods within your resource class:

class ExampleNovaResource extends Resource {

    public function filters(Request $request)
    {
        return [
            new MyFilter()
        ];
    }

}

License

The MIT License (MIT). Please see License File for more information.