add metrics
This commit is contained in:
64
app/Nova/Resources/Order/Loan/Metrics/LoanOrderPerDay.php
Normal file
64
app/Nova/Resources/Order/Loan/Metrics/LoanOrderPerDay.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\Order\Loan\Metrics;
|
||||
|
||||
use App\Models\Order\Loan\LoanOrder;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Metrics\Trend;
|
||||
use Laravel\Nova\Nova;
|
||||
|
||||
class LoanOrderPerDay extends Trend
|
||||
{
|
||||
/**
|
||||
* Get the displayable name of the metric
|
||||
*/
|
||||
public function name(): string
|
||||
{
|
||||
return sprintf('%s (%s)', __('Loan orders'), __('all'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the value of the metric.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function calculate(NovaRequest $request): mixed
|
||||
{
|
||||
return $this->countByDays($request, LoanOrder::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ranges available for the metric.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ranges(): array
|
||||
{
|
||||
return [
|
||||
30 => Nova::__('30 Days'),
|
||||
60 => Nova::__('60 Days'),
|
||||
90 => Nova::__('90 Days'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function uriKey(): string
|
||||
{
|
||||
return 'loan-order-per-day';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user