@php
$currentProfileImage = '';
// Check user's profile_picture field first (set by upload controller)
if ($user->profile_picture && file_exists(public_path('storage/' . $user->profile_picture))) {
$currentProfileImage = asset('storage/' . $user->profile_picture);
} else {
// Fallback: check for files with common extensions
$extensions = ['png', 'jpg', 'jpeg', 'webp'];
foreach ($extensions as $ext) {
$path = 'storage/images/profiles/profile_' . $user->id . '.' . $ext;
if (file_exists(public_path($path))) {
$currentProfileImage = asset($path);
break;
}
}
}
@endphp