PHP code example of digital-creative / nova-slider-filter

1. Go to this page and download the library: Download digital-creative/nova-slider-filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digital-creative / nova-slider-filter example snippets


use DigitalCreative\SliderFilter\SliderFilter;

class MyFilter extends SliderFilter {

    public function apply(NovaRequest $request, $query, $values)
    {
        // $values will be an array when using ->range() and int when using ->single()
    }
    
}

class ExampleNovaResource extends Resource {

    public function filters(NovaRequest $request): array
    {
        return [
            MyFilter::make()->single(min: 0, max: 100),
        ];
    }

}

class ExampleNovaResource extends Resource {

    public function filters(NovaRequest $request): array
    {
        return [
            MyFilter::make()
                ->range(0, 500, 300)
                ->label('${value}')
                
            MyFilter::make()
                ->single(min: 0, max: 500)
                ->label('${value}')
        ];
    }

}

class ExampleNovaResource extends Resource {

    public function filters(NovaRequest $request): array
    {
        return [
            MyFilter::make()
                ->single(0, 100)
                ->marks([
                    '0' => '🌑',
                    '50' => '🌓',
                    '100' => '🌕'
                ])
        ];
    }

}