1. Go to this page and download the library: Download liking/select2-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/ */
liking / select2-filter example snippets
use Liking\Select2Filter\Select2Filter;
class CustomFilter extends Select2Filter
{
/**
* The field used to display as option's label.
* If not config, use default value is `title`
*
* @var string
*/
public $filterTitle = 'title';
/**
* The field used to represent option's value.
* If not config, use default value is `id`
*
* @var string
*/
public $filterId = 'id';
/**
* Name of Nova Resource to search
* If not config, user current Resource
*
* @var string
*/
public $filterResource = '';
....
public function apply(Request $request, $query, $value)
{
$searchValue = Arr::get($value, 'value');
if ($searchValue) {
$query->where('id', $searchValue);
}
return $query;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.