add metrics
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Nova\Dashboards;
|
||||
|
||||
use App\Nova\Resources\Order\Loan\Metrics\LoanOrderPerDay;
|
||||
use App\Nova\Resources\Order\Loan\Metrics\LoanOrderPerStatus;
|
||||
use App\Nova\Resources\Order\Loan\Metrics\NewLoanOrders;
|
||||
use Laravel\Nova\Dashboards\Main as Dashboard;
|
||||
|
||||
class Main extends Dashboard
|
||||
@@ -20,6 +23,9 @@ class Main extends Dashboard
|
||||
public function cards(): array
|
||||
{
|
||||
return [
|
||||
NewLoanOrders::make(),
|
||||
LoanOrderPerDay::make(),
|
||||
LoanOrderPerStatus::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Nova\Resources\Order\Loan\Concerns;
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Loan\LoanType;
|
||||
use App\Nova\Resources\System\Location\Province;
|
||||
use App\Repos\Order\Loan\LoanTypeRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Legal\EducationRepo;
|
||||
use App\Repos\System\Settings\Legal\MarriageRepo;
|
||||
|
||||
@@ -4,8 +4,6 @@ namespace App\Nova\Resources\Order\Loan\Concerns;
|
||||
|
||||
use App\Nova\Resources\Branch\Branch;
|
||||
use App\Nova\Resources\Order\Loan\LoanType;
|
||||
use App\Repos\Branch\BranchRepo;
|
||||
use App\Repos\Order\Loan\LoanTypeRepo;
|
||||
use App\Repos\Order\OrderRepo;
|
||||
use App\Repos\System\Settings\Location\RegionRepo;
|
||||
use Laravel\Nova\Fields\Badge;
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
||||
55
app/Nova/Resources/Order/Loan/Metrics/LoanOrderPerStatus.php
Normal file
55
app/Nova/Resources/Order/Loan/Metrics/LoanOrderPerStatus.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function calculate(NovaRequest $request): mixed
|
||||
{
|
||||
return $this->count($request, LoanOrder::class, 'status')
|
||||
->colors(OrderRepo::statusColors())
|
||||
->label(fn ($value) => match ($value) {
|
||||
null => __('None'),
|
||||
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.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function uriKey(): string
|
||||
{
|
||||
return 'loan-order-per-status';
|
||||
}
|
||||
}
|
||||
53
app/Nova/Resources/Order/Loan/Metrics/NewLoanOrders.php
Normal file
53
app/Nova/Resources/Order/Loan/Metrics/NewLoanOrders.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -183,8 +183,6 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
*/
|
||||
public function setupFieldMacros(): void
|
||||
{
|
||||
Date::macro('toTurkmenFormat', function () {
|
||||
return $this->displayUsing(fn ($value) => $value?->format('d.m.Y'));
|
||||
});
|
||||
Date::macro('toTurkmenFormat', fn () => $this->displayUsing(fn ($value) => $value?->format('d.m.Y')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,6 @@ class OrderRepo
|
||||
*/
|
||||
public static function statusFormatted(string $status = 'pending'): string
|
||||
{
|
||||
return static::values()[$status] ?? __('None');
|
||||
return static::statusValues()[$status] ?? __('None');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,5 +226,6 @@
|
||||
"Now you can set your password, but please make sure that you don't forget it!": "Indi açar sözüni täzeläp bilersiňiz, ýöne ýatdan çykarmaň!",
|
||||
"Your password has been updated": "Siziň açar sözüňiz üýtgedildi",
|
||||
"We send you a verification code to": "Tassyklama belgini şu belgä ugratdyk",
|
||||
"Backups": "Bekaplar"
|
||||
"Backups": "Bekaplar",
|
||||
"all": "ählisi"
|
||||
}
|
||||
|
||||
4
lang/vendor/nova/tk.json
vendored
4
lang/vendor/nova/tk.json
vendored
@@ -288,8 +288,8 @@
|
||||
"No Current Data": "Häzirki maglumatlar ýok",
|
||||
"No Data": "Maglumat ýok",
|
||||
"no file selected": "faýl saýlanmady",
|
||||
"No Increase": "Okarlandyrma",
|
||||
"No Prior Data": "Öňünden maglumat ýok",
|
||||
"No Increase": "Ýokarlanma ýok",
|
||||
"No Prior Data": "Öňki maglumat ýok",
|
||||
"No Results Found.": "Netije tapylmady",
|
||||
"Norfolk Island": "Norfolk adasy",
|
||||
"Northern Mariana Islands": "Demirgazyk Mariana adalary",
|
||||
|
||||
Reference in New Issue
Block a user