54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Nova\Resources\Order\Loan\Metrics;
|
|
|
|
use App\Models\Order\Loan\LoanOrder;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
use Laravel\Nova\Metrics\Value;
|
|
use Laravel\Nova\Nova;
|
|
|
|
class NewLoanOrders extends Value
|
|
{
|
|
/**
|
|
* 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);
|
|
}
|
|
|
|
/**
|
|
* Get the ranges available for the metric.
|
|
*/
|
|
public function ranges(): array
|
|
{
|
|
return [
|
|
30 => Nova::__('30 Days'),
|
|
60 => Nova::__('60 Days'),
|
|
365 => Nova::__('365 Days'),
|
|
'TODAY' => Nova::__('Today'),
|
|
'MTD' => Nova::__('Month To Date'),
|
|
'QTD' => Nova::__('Quarter To Date'),
|
|
'YTD' => Nova::__('Year To Date'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|