This commit is contained in:
Saufi
2026-06-03 08:51:22 +08:00
commit a14d43fe34
347 changed files with 38197 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Admin\Management;
use App\Http\Controllers\Controller;
use App\Models\Application;
use App\Models\JkmRepresentative;
use App\Models\KkmRepresentative;
use App\Models\PoliceEscort;
use App\Models\StaffAssignment;
use App\Models\WheelchairAllocation;
use App\Services\Admin\Management\WheelchairManagementService;
use Illuminate\View\View;
class AdminManagementController extends Controller
{
public function index(WheelchairManagementService $wheelchairService): View
{
$allocations = WheelchairAllocation::query()->with('transactions')->get();
return view('admin.management.index', [
'counts' => [
'applications' => Application::query()->count(),
'assigned' => Application::query()->where('status', 'assigned')->count(),
'staffAssignments' => StaffAssignment::query()->where('status', 'active')->count(),
'representatives' => PoliceEscort::query()->count() + KkmRepresentative::query()->count() + JkmRepresentative::query()->count(),
'missingDocuments' => Application::query()
->whereDoesntHave('documents', fn ($query) => $query->where('document_type', 'ic_document'))
->orWhereDoesntHave('documents', fn ($query) => $query->where('document_type', 'bank_statement'))
->count(),
'incompleteBank' => Application::query()
->where(fn ($query) => $query->whereNull('bank_name')->orWhereNull('bank_account_number'))
->count(),
'wheelchairAllocated' => $allocations->sum('allocated_quantity'),
'wheelchairOutstanding' => $allocations->sum(fn (WheelchairAllocation $allocation): int => $wheelchairService->outstandingQuantity($allocation)),
],
]);
}
}