first
This commit is contained in:
@@ -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)),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user