PHP code example of huuloc4193 / nova-range-input-filter
1. Go to this page and download the library: Download huuloc4193/nova-range-input-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/ */
huuloc4193 / nova-range-input-filter example snippets
use DigitalCreative\RangeInputFilter\RangeInputFilter;
class MyFilter extends RangeInputFilter {
public function apply(NovaRequest $request, $query, $value)
{
$from = data_get($value, 'from');
$to = data_get($value, 'to');
return $query->where(function ($q) use ($from, $to) {
if ($from) {
$q->where('id', '>=', $from);
}
if ($to) {
$q->where('id', '<=', $to);
}
});
}
}
class ExampleNovaResource extends Resource {
public function filters(NovaRequest $request): array
{
return [
MyFilter::make()
];
}
}
class ExampleNovaResource extends Resource {
public function filters(NovaRequest $request): array
{
return [
MyFilter::make()
->dividerLabel('<>') // control the divider label in between the inputs
->inputType('week') // supports any html input type
->placeholder('From', 'To') // control the placeholder of the inputs
->fromAttributes([ 'min' => 0 ]) // some inputs type like number accepts more attributes like min/max/step etc..
->toAttributes([ 'max' => 100 ])
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.