implement admin panel

This commit is contained in:
Meghdad committed 2026-07-22 17:22:33 +03:30
1 parent 56a52be180
commit e8223fbc3e
92 files changed
+5426 -9

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Filament\Widgets;
use App\Domain\Loan\Enums\LoanStatus;
use App\Models\Loan;
use Filament\Widgets\ChartWidget;
class LoanStatusChart extends ChartWidget
{
protected ?string $heading = 'Portfolio by status';
protected ?string $description = 'Distribution across the automatic processing lifecycle.';
protected static bool $isLazy = false;
protected int|string|array $columnSpan = 1;
protected function getData(): array
{
$counts = Loan::query()
->select('status')
->selectRaw('COUNT(*) AS aggregate')
->groupBy('status')
->pluck('aggregate', 'status');
$statuses = LoanStatus::cases();
return [
'datasets' => [[
'label' => 'Loans',
'data' => array_map(fn (LoanStatus $status): int => (int) $counts->get($status->value, 0), $statuses),
'backgroundColor' => ['#94a3b8', '#38bdf8', '#f59e0b', '#10b981', '#ef4444'],
'borderWidth' => 0,
]],
'labels' => array_map(fn (LoanStatus $status): string => str($status->value)->headline()->toString(), $statuses),
];
}
protected function getType(): string
{
return 'doughnut';
}
}