{{-- resources/views/public/athlete_detail.blade.php --}} @php $ageNumber = $featuredAthlete->date_of_birth ? $featuredAthlete->date_of_birth->age : '-'; $ageCategories = '-'; if(is_array($featuredAthlete->age_category) && count($featuredAthlete->age_category) > 0) { $ageCategories = implode(', ', $featuredAthlete->age_category); } $specialties = collect(); $competitionCategories = collect(); if ($featuredAthlete->performances) { foreach ($featuredAthlete->performances as $perf) { if ($perf->discipline) { $specialties->push($perf->discipline->name); if ($perf->discipline->category) { $competitionCategories->push($perf->discipline->category->name); } } } } $specialtiesText = $specialties->unique()->count() > 0 ? $specialties->unique()->implode(', ') : '-'; $categoriesText = $competitionCategories->unique()->count() > 0 ? $competitionCategories->unique()->implode(', ') : '-'; $pbText = '-'; $sbText = '-'; $hasNationalRecord = false; if ($featuredAthlete->performanceHistories) { $pbs = $featuredAthlete->performanceHistories->filter(function($h) { return $h->performanceRemarks->contains('code', 'PB'); })->sortByDesc('date'); if ($pbs->count() > 0) { $bestPb = $pbs->first(); $pbText = $bestPb->result_mark . ' (' . ($bestPb->discipline->name ?? '') . ')'; } $sbs = $featuredAthlete->performanceHistories->filter(function($h) { return $h->performanceRemarks->contains('code', 'SB'); })->sortByDesc('date'); if ($sbs->count() > 0) { $bestSb = $sbs->first(); $sbText = $bestSb->result_mark . ' (' . ($bestSb->discipline->name ?? '') . ')'; } $hasNationalRecord = $featuredAthlete->performanceHistories->contains(function($h) { return $h->performanceRemarks->contains('code', 'NR'); }); } $groupedHistories = $featuredAthlete->performanceHistories->groupBy(function($item) { return $item->discipline->name; }); $achievements = $featuredAthlete->performanceHistories->filter(function($h) { return in_array($h->place, [1, 2, 3]); })->sortByDesc('date'); $chartData = []; foreach($groupedHistories as $discName => $items) { $sortedItems = $items->sortBy('date'); $chartData[$discName] = $sortedItems->map(function($h) { $cleanResult = preg_replace('/[^0-9.]/', '', $h->result_mark); return [ 'x' => $h->date->format('Y-m-d'), 'y' => (float) $cleanResult, 'formatted' => $h->result_mark, 'venue' => $h->venue, 'event' => $h->competition_name, 'type' => $h->discipline->result_type ]; })->values(); } @endphp
@if($featuredAthlete->photo) @else @endif
@if($featuredAthlete->status == 'active')
AKTIF
@else
NONAKTIF
@endif

{{ $featuredAthlete->name }}

@if($hasNationalRecord) Pemegang Rekor Nasional @endif
{{ $categoriesText }}
{{ $specialtiesText }}
{{ $featuredAthlete->gender == 'male' ? 'PUTRA' : 'PUTRI' }}
@foreach([ ['label' => 'Domisili', 'val' => $featuredAthlete->province_name], ['label' => 'Usia', 'val' => $ageNumber . ' Tahun (' . $ageCategories . ')'], ['label' => 'Personal Best', 'val' => $pbText, 'isResult' => true], ['label' => 'Season Best', 'val' => $sbText, 'isResult' => true] ] as $item)

{{ $item['label'] }}

{{ $item['val'] }}

@endforeach
@include('public.athlete_detail_best') @include('public.athlete_detail_grafik') @include('public.athlete_detail_honours') @include('public.athlete_detail_history') @include('public.athlete_detail_script')