oleksiypetlyuk / nova-range-filter
A Laravel Nova filter.
Installs: 62 679
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 1
Open Issues: 2
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-04-27 00:59:03 UTC
README
Nova Range Filter
A custom vue component that fully supports filtering over a range of values based on Vue Slider Component
Installation
You can install the package into a Laravel application that uses Nova via composer:
composer require oleksiypetlyuk/nova-range-filter
Usage
Just use the Oleksiypetlyuk\NovaRangeFilter\NovaRangeFilter
field in your Nova filter:
<?php namespace App\Nova\Filters\Profile; use App\Models\Profile\Profile; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; use Oleksiypetlyuk\NovaRangeFilter\NovaRangeFilter; class HourlyPriceFilter extends NovaRangeFilter { public $name = 'Price range'; public function __construct() { $this->min = floor(Profile::min('hourly_price')); $this->max = ceil(Profile::max('hourly_price')); parent::__construct(); } /** * Apply the filter to the given query. * * @param Request $request * @param Builder $query * @param mixed $value * @return Builder */ public function apply(Request $request, $query, $value) { return $query->whereBetween('hourly_price', $value) ->orWhereNull('hourly_price'); } }
Contributions
All contributions (big or small) are highly welcomed. Send a PR
Authors
- Oleksiy Petlyuk oleksiy.petlyuk94@gmail.com
Support
If you would love to support the continuous development and maintenance of this package, please consider buying me a coffee.
License
This package is open-sourced software licensed under the MIT License