codicastudio/range-filter

A random Codica Studio package.

1.0.0 2020-09-23 07:01 UTC

This package is auto-updated.

Last update: 2024-12-25 14:53:46 UTC


README

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) : array
    {
        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.