{{-- --}} @php $applications = App\Models\Application::query(); $pendingStatuses = [ App\Models\Application::STATUS_SUBMITTED, App\Models\Application::STATUS_PENDING_SCREENING_APPROVAL, App\Models\Application::STATUS_PENDING_JR_APPROVAL, App\Models\Application::STATUS_PENDING_SR_APPROVAL, App\Models\Application::STATUS_PENDING_PL_APPROVAL, App\Models\Application::STATUS_PENDING_PD_APPROVAL, App\Models\Application::STATUS_PENDING_ADMIN_APPROVAL, ]; if (auth()->user()->hasRole('Screening Officer')) { $applications->where('stage', App\Models\Application::STAGE_SO); } else if (auth()->user()->hasRole('Junior Evaluator')) { $applications->where('stage', App\Models\Application::STAGE_JE)->whereHas('je_evaluation', function ($q) { $q->where('user_id', auth()->user()->id); }); } else if (auth()->user()->hasRole('Senior Evaluator')) { $applications->where('stage', App\Models\Application::STAGE_SE)->whereHas('se_evaluation', function ($q) { $q->where('user_id', auth()->user()->id); }); } else if (auth()->user()->hasRole('Project Leader')) { $applications->where('stage', App\Models\Application::STAGE_PL)/* ->whereHas('pl_evaluation', function ($q) { $q->where('user_id', auth()->user()->id); }) */; } else if (auth()->user()->hasRole('Project Director')) { $applications->where('stage', App\Models\Application::STAGE_PD)/* ->whereHas('pd_evaluation', function ($q) { $q->where('user_id', auth()->user()->id); }) */; } else if (auth()->user()->hasRole('administrator')) { $applications->where('stage', App\Models\Application::STAGE_AA); } $normalLaneCount = (clone $applications)->whereHas('payment.pricing', function ($q) { $q->where('lane', App\Models\PricingScheme::LANE_NORMAL); })->whereIn('applications.status', $pendingStatuses)->count(); $fastLaneCount = (clone $applications)->whereHas('payment.pricing', function ($q) { $q->where('lane', App\Models\PricingScheme::LANE_FAST); })->whereIn('applications.status', $pendingStatuses)->count(); $superFastLaneCount = (clone $applications)->whereHas('payment.pricing', function ($q) { $q->where('lane', App\Models\PricingScheme::LANE_SUPER_FAST); })->whereIn('applications.status', $pendingStatuses)->count(); $incompleteApplications = App\Models\Application::where('status', App\Models\Application::STATUS_INCOMPLETE)->count() ?? 0; $replacements = [ '__normalLane__' => $normalLaneCount, '__fastLane__' => $fastLaneCount, '__superFastLane__' => $superFastLaneCount, '__incomplete__' => $incompleteApplications, ]; // Replace placeholders $menusJson = json_encode($menus); $menusJson = str_replace(array_keys($replacements), array_values($replacements), $menusJson); $menus = json_decode($menusJson, true); @endphp @foreach ($menus as $menu) @if (!empty($menu['submenu'])) @php $routes = is_array($menu['route']) ? $menu['route'] : [$menu['route']]; $match = false; foreach ($routes as $r) { // If the route has a dot, match it and its subroutes if (Str::contains($r, '.')) { if (request()->routeIs($r) || request()->routeIs($r . '.*')) { $match = true; break; } } else { // Match route and its subroutes if (request()->routeIs($r) || request()->routeIs($r . '.*')) { $match = true; break; } } } @endphp @else @endif @endforeach