{{-- Trigger Button --}} @php // Get active profile info to exclude from unread check $activeProfileType = session('activeProfileType'); $activeProfileId = session('activeProfileId'); $activeTypeKey = null; if ($activeProfileType) { $activeTypeKey = match($activeProfileType) { 'App\\Models\\User', 'App\Models\User' => 'user', 'App\\Models\\Admin', 'App\Models\Admin' => 'admin', 'App\\Models\\Bank', 'App\Models\Bank' => 'bank', 'App\\Models\\Organization', 'App\Models\Organization' => 'organization', default => null }; } // Check if any NON-ACTIVE profile has unread messages $hasAnyUnread = false; // Check user profile (only if not active) if ($activeTypeKey !== 'user') { $hasAnyUnread = $profilesWithUnread['user'] ?? false; } if (!$hasAnyUnread) { foreach (['admin', 'bank', 'organization'] as $type) { if (!empty($profilesWithUnread[$type])) { foreach ($profilesWithUnread[$type] as $profileId => $hasUnread) { // Skip if this is the active profile if ($activeTypeKey === $type && $activeProfileId == $profileId) { continue; } if ($hasUnread) { $hasAnyUnread = true; break 2; } } } } } @endphp {{-- Dropdown Content --}} {{ \Illuminate\Support\Str::limit($userName, 25, '...') }} @if(($profilesWithUnread['user'] ?? false) && $activeTypeKey !== 'user') @endif
@foreach($userProfiles as $index => $userProfile) @php // Check if this is the active profile $isActiveProfile = ($activeTypeKey === $userProfile['type'] && $activeProfileId == $userProfile['id']); @endphp {{ \Illuminate\Support\Str::limit($userProfile['name'], 25, '...') }} @if(($profilesWithUnread[$userProfile['type']][$userProfile['id']] ?? false) && !$isActiveProfile) @endif @endforeach