{{-- resources/views/admin/athletes/index.blade.php --}} @extends('admin.layouts.app') @section('content')
@include('admin.athletes._header_stats')

Data Atlet @if(request('training_origin')) | {{ request('training_origin') }} @endif

@if(request()->has('training_origin')) @endif
@if(request('search') || request('specialty_category') || request('training_origin')) @endif
@if(session('success')) @endif @if(session('error')) @endif @php $activeAthletes = $athletes->where('status', 'active'); $inactiveAthletes = $athletes->where('status', 'inactive'); $fixedAgeCategories = ['Master', 'Elite', 'U-20', 'U-18', 'U-16']; $checkCategory = function($athlete, $targetAge) { $raw = $athlete->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); $targetAgeLower = strtolower($targetAge); $targetAgeCleanLower = str_replace('-', '', $targetAgeLower); return str_contains($rawString, $targetAgeLower) || str_contains($rawString, $targetAgeCleanLower); }; @endphp
@include('admin.athletes._table', ['athleteCollection' => $activeAthletes, 'emptyMessage' => 'Belum ada data atlet aktif.'])
@foreach($fixedAgeCategories as $age) @php $athletesInThisAge = $activeAthletes->filter(function($athlete) use ($age, $checkCategory) { return $checkCategory($athlete, $age); }); $tabId = Str::slug($age); @endphp
@include('admin.athletes._table', ['athleteCollection' => $athletesInThisAge, 'emptyMessage' => "Belum ada atlet aktif di kategori $age."])
@endforeach
@include('admin.athletes._table', ['athleteCollection' => $inactiveAthletes, 'emptyMessage' => 'Tidak ada data atlet nonaktif/pensiun.'])
@endsection