{{-- resources/views/admin/competitors/_header_stats.blade.php --}} @if(isset($competitors)) @php $totalCompetitors = $competitors->count(); $totalMale = $competitors->where('gender', 'male')->count(); $totalFemale = $competitors->where('gender', 'female')->count(); $checkCat = function($comp, $targetAge) { $raw = $comp->age_category; if (empty($raw)) return false; if (is_array($raw)) { return in_array($targetAge, $raw) || in_array(str_replace('-', '', $targetAge), $raw); } $rawString = strtolower((string) $raw); return str_contains($rawString, strtolower($targetAge)) || str_contains($rawString, str_replace('-', '', strtolower($targetAge))); }; $statsAge = [ 'U-16' => $competitors->filter(fn($c) => $checkCat($c, 'U-16'))->count(), 'U-18' => $competitors->filter(fn($c) => $checkCat($c, 'U-18'))->count(), 'U-20' => $competitors->filter(fn($c) => $checkCat($c, 'U-20'))->count(), 'Elite' => $competitors->filter(fn($c) => $checkCat($c, 'Elite'))->count(), 'Master' => $competitors->filter(fn($c) => $checkCat($c, 'Master'))->count(), ]; @endphp

{{ $totalCompetitors }}

Total Kompetitor

{{ $totalMale }} Putra
{{ $totalFemale }} Putri

Gender
Kelompok Umur
{{ $statsAge['U-16'] }}
U-16
{{ $statsAge['U-18'] }}
U-18
{{ $statsAge['U-20'] }}
U-20
{{ $statsAge['Elite'] }}
Elite
@endif