{{-- 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
{{ $item['label'] }}
{{ $item['val'] }}