Files
online.tbbank.gov.tm-larave…/app/Nova/Resources/Order/Loan/Metrics/LoanOrderPerStatus.php
2024-05-06 17:13:38 +05:00

50 lines
1.2 KiB
PHP

<?php
namespace App\Nova\Resources\Order\Loan\Metrics;
use App\Models\Order\Loan\LoanOrder;
use App\Repos\Order\OrderRepo;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Partition;
class LoanOrderPerStatus extends Partition
{
/**
* Get the displayable name of the metric
*/
public function name(): string
{
return sprintf('%s (%s)', __('Loan orders'), __('all'));
}
/**
* Calculate the value of the metric.
*/
public function calculate(NovaRequest $request): mixed
{
return $this->count($request, LoanOrder::class, 'status')
->colors(OrderRepo::statusColors())
->label(fn ($value) => match ($value) {
default => OrderRepo::statusFormatted($value)
});
}
/**
* Determine the amount of time the results of the metric should be cached.
*
* @return \DateTimeInterface|\DateInterval|float|int|null
*/
public function cacheFor()
{
// return now()->addMinutes(5);
}
/**
* Get the URI key for the metric.
*/
public function uriKey(): string
{
return 'loan-order-per-status';
}
}