@php // Helper function to calculate age at a specific date with detailed format function calculateAgeAtDate($birthdate, $date) { if (!$birthdate || !$date) return null; $birth = \Carbon\Carbon::parse($birthdate); $targetDate = \Carbon\Carbon::parse($date); $diff = $birth->diff($targetDate); $parts = []; if ($diff->y > 0) $parts[] = $diff->y . ' year' . ($diff->y > 1 ? 's' : ''); if ($diff->m > 0) $parts[] = $diff->m . ' month' . ($diff->m > 1 ? 's' : ''); if ($diff->d > 0) $parts[] = $diff->d . ' day' . ($diff->d > 1 ? 's' : ''); return implode(' ', $parts) ?: 'Same day'; } @endphp
Club Affiliations & Skills Journey

Complete history of club memberships, skills acquired, and instructors

@if($clubAffiliations->count() > 0)

{{ $totalAffiliations }}

Total Clubs

{{ $distinctSkills }}

Unique Skills

{{ floor($totalMembershipDuration / 12) }}y {{ $totalMembershipDuration % 12 }}m

Total Training

{{ $totalInstructors ?? 0 }}

Instructors
Membership Timeline
@foreach($clubAffiliations as $index => $affiliation) @php $ageAtStart = calculateAgeAtDate($user->birthdate, $affiliation->start_date); $ageAtEnd = $affiliation->end_date ? calculateAgeAtDate($user->birthdate, $affiliation->end_date) : null; $isOngoing = !$affiliation->end_date; // Get all skills for this affiliation $affiliationSkills = $affiliation->skillAcquisitions ?? collect(); $skillNames = $affiliationSkills->pluck('skill_name')->unique()->implode(','); @endphp
@if($affiliation->logo) {{ $affiliation->club_name }} @else
@endif
{{ $affiliation->club_name }}
@if($affiliation->start_date) {{ $affiliation->start_date->format('M Y') }} - {{ $isOngoing ? 'Present' : ($affiliation->end_date ? $affiliation->end_date->format('M Y') : 'N/A') }} @endif @if($affiliation->formatted_duration) {{ $affiliation->formatted_duration }} @endif @if($ageAtStart) Age: {{ $ageAtStart }}{{ $ageAtEnd && $ageAtEnd != $ageAtStart ? " to $ageAtEnd" : '' }} @endif
@if($isOngoing) Active @endif
@if($affiliation->location)
{{ $affiliation->location }}
@endif @if($affiliationSkills->count() > 0)
Skills Acquired ({{ $affiliationSkills->count() }})
@foreach($affiliationSkills as $skill) {{ $skill->skill_name }} {{ ucfirst($skill->proficiency_level) }} @endforeach
@endif @if($affiliation->subscriptions && $affiliation->subscriptions->count() > 0)
Training Packages ({{ $affiliation->subscriptions->count() }})
@foreach($affiliation->subscriptions as $subIndex => $subscription) @if($subscription->package) @endif @endforeach
@endif @php $instructors = $affiliationSkills->pluck('instructor')->filter()->unique('id'); @endphp @if($instructors->count() > 0)
Instructors ({{ $instructors->count() }})
@foreach($instructors as $instructor)
{{ strtoupper(substr($instructor->user->full_name ?? 'I', 0, 1)) }}
{{ $instructor->user->full_name ?? 'Unknown' }}
{{ $instructor->role ?? 'Instructor' }}
@endforeach
@endif
@endforeach
@php $allInstructors = collect(); foreach($clubAffiliations as $aff) { $affInstructors = $aff->skillAcquisitions->pluck('instructor')->filter()->unique('id'); $allInstructors = $allInstructors->merge($affInstructors); } $allInstructors = $allInstructors->unique('id'); @endphp @foreach($allInstructors as $instructor) @endforeach @foreach($clubAffiliations as $affiliation) @foreach($affiliation->subscriptions as $subIndex => $subscription) @if($subscription->package) @endif @endforeach @endforeach
@else
No Affiliations Yet

Club affiliations and skills will appear here once added

@endif