@php $scheme = $schemeModel ?? null; $plan = $planModel ?? null; $teamUsers = $teamUsers ?? collect(); $teamRows = $teamUsers instanceof \Illuminate\Support\Collection ? $teamUsers->all() : (array) $teamUsers; $teamByRegion = collect($teamRows)->groupBy(fn ($r) => (string) ($r['region'] ?? 'Other')); $teamRegionsOrdered = $teamByRegion->keys()->sort(function ($a, $b) { if ($a === 'Other' && $b !== 'Other') { return 1; } if ($b === 'Other' && $a !== 'Other') { return -1; } return strcmp((string) $a, (string) $b); })->values(); $visitDate = $scheme?->visit_date ? $scheme->visit_date->format('Y-m-d') : ''; $additionalDates = $scheme?->dates?->pluck('visit_date')->map(fn ($d) => $d->format('Y-m-d'))->values()->all() ?? []; $visitingTeamIds = $scheme?->visitingTeams?->pluck('user_id')->values()->all() ?? []; @endphp @if($plan && $scheme)
@endif