Download the PHP package bourne/dependent-filter without Composer
On this page you can find all versions of the php package bourne/dependent-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dependent-filter
Nova Dependent Filter
This package provides filters what depends of another filters.
- Installation
- Usage
- Declaration
- Class declaration
- Static dependencies
- Dynamic dependencies
- Hiding empty filters
- Default filter value
- Other stuffs
- Thanks
Installation
You can install the package in to a Laravel app that uses Nova via composer:
Usage
Declaration
You can declare filters in you filters method directly:
Also you can use DependentFilter::make()
instead new DependentFilter()
.
For queries you need to use callback declaration:
Note: In difference with Nova filters filter's
value
need pass as array key andlabel
as array value.
Class declaration
As is Nova filters you can create filter's class:
Note: The
fresh
method is identical with the callback for declaring options.
Static dependencies
For creating dependent filter you need to specify dependent filters values at which the option will be shown:
Note. Instead of an attribute or class name, you must specify the key of the filter.
Dynamic dependencies
For big collection of data you can use dynamic updating of the filter.
In class declaration you also need to set $dependentOf
property:
If you want to show options only when main filter is selected you can use when
for check it:
Hiding empty filters
You can hide filters until they have options.
For it you need set $hideWhenEmpty
or call hideWhenEmpty()
method:
Default filter value
If you want to set default value you need to call withDefault
method with value or overload default
method in class declaration.
Other stuffs
By default filter checking by equal filed specified in $attribute
and filter value. You can overload it like as in Nova filters:
When you use declare style you can set pass apply callback to withApply
method:
Also you can specify another filter key over method key
.
Thanks
Thanks to Brian for his support and advices.