31 lines
677 B
PHP
31 lines
677 B
PHP
<?php
|
|
|
|
namespace App\Nova\Metrics;
|
|
|
|
use Laravel\Nova\Metrics\Partition;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
use App\Models\Vehicle;
|
|
use Laravel\Nova\Metrics\PartitionResult;
|
|
|
|
class VehiclesPerStatus extends Partition
|
|
{
|
|
/**
|
|
* Calculate the partition metric.
|
|
*/
|
|
public function calculate(NovaRequest $request): PartitionResult
|
|
{
|
|
return $this->count($request, Vehicle::class, 'status')
|
|
->label(function ($value) {
|
|
return ucfirst(str_replace('_', ' ', $value));
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Get the metric's URI key.
|
|
*/
|
|
public function uriKey()
|
|
{
|
|
return 'vehicles-per-status';
|
|
}
|
|
}
|