@php // Detect user's actual role from their data $userRole = $user->role_slug; // Get appropriate profile based on detected user role (not global $currentRole) $profile = ($userRole === 'team') ? $user->teamProfile : $user->athleteProfile; $primarySport = $user->sports->first(); // Get location $location = ''; if ($profile) { $locationParts = array_filter([ optional($profile->city)->city_name, optional($profile->state)->state_name, optional($profile->country)->country_name ]); $location = implode(', ', $locationParts); } // Get social link icon $socialIcon = null; if ($user->socialLinks && $user->socialLinks->count() > 0) { $firstLink = $user->socialLinks->first(); switch($firstLink->social_link_type) { case 1: $socialIcon = asset('front/assets/images/youtube.png'); break; case 2: $socialIcon = asset('front/assets/images/instagram.png'); break; case 3: $socialIcon = asset('front/assets/images/facebook.png'); break; } } // Get gender icon $genderIcon = $userRole === 'athlete' ? ($user->gender == 1 ? asset('front/assets/images/male.svg') : asset('front/assets/images/female.svg')) : ''; // Get sport info and icon from master_sports (use detected user role, not global currentRole) $sportName = ''; $sportIcon = asset('img/no-image.png'); // Default fallback $positionName = ''; $userTypeBadge = ($userRole === 'team') ? asset('front/assets/images/team.png') : asset('front/assets/images/athelete.png'); if ($userRole === 'team' && $profile && $profile->sport) { $sportName = optional($profile->sport)->title ?? 'Team'; // Get sport icon from master_sports -> files table (image accessor returns array) $sportImageData = $profile->sport->image ?? []; if (is_array($sportImageData) && isset($sportImageData['original']) && is_string($sportImageData['original'])) { $sportIcon = $sportImageData['original']; } } elseif ($userRole === 'athlete' && $primarySport && $primarySport->sport) { // $primarySport is UserMasterSportMap, need to access ->sport $sportName = optional($primarySport->sport)->title ?? ''; // Get sport icon from master_sports -> files table (image accessor returns array) $sportImageData = optional($primarySport->sport)->image ?? []; if (is_array($sportImageData) && isset($sportImageData['original']) && is_string($sportImageData['original'])) { $sportIcon = $sportImageData['original']; } if ($profile && $profile->position) { $positionName = optional($profile->position)->title ?? ''; } } $bio = optional($profile)->athlete_bio ?? optional($profile)->team_bio_tagline ?? 'No bio available'; $schoolClub = optional($user)->school_club_name ?? optional($profile)->team_club_name ?? 'N/A'; // Get active campaign for this user $userCampaign = null; if (isset($activeCampaigns[$user->id]) && $activeCampaigns[$user->id]->count() > 0) { $userCampaign = $activeCampaigns[$user->id]->first(); } @endphp @if($loop->first || $loop->iteration % 3 == 1)
@endif
{{ $user->full_name }}
{{ $sportName }}
@if($userRole === 'team') {{ $schoolClub }} @else {{ $user->full_name }} @if($genderIcon) Gender @endif @endif
@if($sportName) {{ $sportName }} @if($positionName) – {{ $positionName }} @endif @endif
@if($socialIcon) @endif
{{ ucfirst($userRole)}}
Short Bio
{{ Str::limit($bio, 100) }}
@if($location)
{{ $location }}
@endif
@if($userRole === 'team')
Team Size {{$profile->team_size ?? 'N/A'}}
@else @endif
@if($userCampaign) @php $campaignProgress = $userCampaign->fund_target > 0 ? ($userCampaign->fund_raised / $userCampaign->fund_target) * 100 : 0; $campaignProgress = min(100, max(0, $campaignProgress)); $daysLeft = $userCampaign->campaign_finished_at ? now()->diffInDays(\Carbon\Carbon::parse($userCampaign->campaign_finished_at), false) : 0; @endphp
Campaign Summary
{{ Str::limit($userCampaign->title ?? $userCampaign->summary ?? 'Active Campaign', 50) }}
Raised : {!! \App\Helpers\Helper::price($userCampaign->fund_raised) !!}
{{ number_format($campaignProgress, 0) }}%
Goal : {!! \App\Helpers\Helper::price($userCampaign->fund_target) !!}
{{ max(0, round($daysLeft)) }} days left
@else
Campaign Summary
No active campaign
Raised : {!! \App\Helpers\Helper::price(0) !!}
0%
Goal : {!! \App\Helpers\Helper::price(0) !!}
No active campaign
@endif
@if($loop->iteration % 3 == 0 || $loop->last)
@endif