@php // Detect user's actual role from their data $userRole = $user->role_slug; // Get appropriate profile based on detected user role $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 sport info and sport image $sportName = ''; $positionName = ''; $sportImage = null; if ($userRole === 'team' && $profile && $profile->sport) { $sportName = optional($profile->sport)->title ?? 'Team'; $sportImageData = optional($profile->sport)->image ?? []; if (is_array($sportImageData) && isset($sportImageData['original']) && is_string($sportImageData['original'])) { $sportImage = $sportImageData['original']; } } elseif ($userRole === 'athlete' && $primarySport && $primarySport->sport) { $sportName = optional($primarySport->sport)->title ?? ''; $sportImageData = optional($primarySport->sport)->image ?? []; if (is_array($sportImageData) && isset($sportImageData['original']) && is_string($sportImageData['original'])) { $sportImage = $sportImageData['original']; } if ($profile && $profile->position) { $positionName = optional($profile->position)->title ?? ''; } } // Get bio $bio = optional($profile)->athlete_bio ?? optional($profile)->team_bio_tagline ?? 'No bio available'; // Get school/club name $schoolClub = optional($profile)->school_club_name ?? optional($profile)->team_club_name ?? ''; // Get avatar and check if we need to show initials $avatarData = $user->avatar ?? []; $hasAvatar = isset($avatarData['id']) && $avatarData['id']; $avatar = $hasAvatar ? ($avatarData['thumb'] ?? $avatarData['original'] ?? asset('front/assets/images/thumb1.png')) : null; // Generate initials if no avatar $userInitials = ''; $initialColorType = 1; if (!$hasAvatar) { if ($user->name_initials) { $userInitials = strtoupper($user->name_initials); $initialColorType = $user->name_initial_color_type ?? 1; } else { // Generate from first and last name $firstName = $user->first_name ?? ''; $lastName = $user->last_name ?? ''; $userInitials = strtoupper(mb_substr($firstName, 0, 1) . mb_substr($lastName, 0, 1)); // Generate deterministic color based on name $nameHash = crc32($user->full_name ?? ''); $initialColorType = ($nameHash % 8) + 1; } } // Get stats $userStats = $usersStats[$user->id] ?? ['followers' => 0, 'campaigns' => 0, 'raised' => 0]; $followersCount = $userStats['followers']; $campaignsCount = $userStats['campaigns']; $raisedAmount = $userStats['raised']; // Format followers count $followersFormatted = $followersCount >= 1000 ? number_format($followersCount / 1000, 0) . 'K' : $followersCount; // Get social links $socialLinks = $user->socialLinks ?? collect(); $instagramLink = $socialLinks->where('social_link_type', 2)->first(); $facebookLink = $socialLinks->where('social_link_type', 3)->first(); $youtubeLink = $socialLinks->where('social_link_type', 1)->first(); // Get sport tags (for display) $sportTags = []; if ($primarySport && $primarySport->sport) { $sportTags[] = $primarySport->sport->title ?? ''; } if ($positionName) { $sportTags[] = $positionName; } // Check if user is verified $isVerified = $user->verified ?? false; @endphp
@if($sportImage)
{{ $sportName }}
@else
@endif
@if($hasAvatar && $avatar) {{ $user->full_name }} @else
{{ $userInitials }}
@endif @if($isVerified)
@endif
{{ strtoupper($userRole) }}

@if($userRole === 'team') {{ $schoolClub ?: $user->full_name }} @else {{ $user->full_name }} @endif

@if($sportName) {{ $sportName }} @if($positionName) • {{ $positionName }} @endif @endif @if($schoolClub && $userRole === 'athlete') • {{ $schoolClub }} @endif

@if($location)

{{ $location }}

@endif

{{ Str::limit($bio, 120) }}

@if(count($sportTags) > 0)
@foreach(array_slice($sportTags, 0, 3) as $tag) @if($tag) {{ $tag }} @endif @endforeach
@endif
Followers {{ $followersFormatted }}
Campaigns {{ $campaignsCount }}
Raised {!! \App\Helpers\Helper::price($raisedAmount) !!}
View Profile
@php // Get Twitter/X link (social_link_type 4 or check for X/Twitter in URL) $twitterLink = $socialLinks->first(function($link) { if ($link->social_link_type == 4) { $url = strtolower($link->social_link ?? ''); return strpos($url, 'twitter') !== false || strpos($url, 'x.com') !== false || strpos($url, 'twitter.com') !== false; } return false; }); @endphp @if($twitterLink) @endif @if($instagramLink) @endif @if($facebookLink) @endif