1. Go to this page and download the library: Download granello/nova-global-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/ */
granello / nova-global-filter example snippets
...
use Granello\NovaGlobalFilter\NovaGlobalFilter;
use App\Nova\Filters\Date;
class Store extends Resource
{
...
public function cards(Request $request)
{
return [
new TotalSales // Value Metric
new Orders, // Trend Metric
new MostSoldProduct, // Partition Metric
// NovaGlobalFilter
new NovaGlobalFilter([
new Date, // Date Filter
]),
];
}
...
}
use Granello\NovaGlobalFilter\GlobalFilterable;
use App\Nova\Filters\Date;
...
class UsersPerDay extends Trend
{
use GlobalFilterable;
public function calculate(NovaRequest $request)
{
// Filter your model with existing filters
$model = $this->globalFiltered($request, Store::class,[
Date::class // DateFilter
]);
// Do your thing with the filtered $model
return $this->countByDays($request, $model);
}
...
}
...
// set default date
public function default()
{
return Carbon::now();
}
...
...
(new NovaGlobalFilter([
// Filters
]))->inline(),
...
...
(new NovaGlobalFilter([
// Filters
]))->resettable(),
...
...
(new NovaGlobalFilter([
// Filters
]))->inline()->resettable(),
(new NovaGlobalFilter([
// Filters
]))->onlyOnDetail(),
...
...
(new NovaGlobalFilter([
// Filters
]))->title('Example Title'),
...