@php $hasActiveConversation = isset($activeConversation); $currentId = $currentUserId ?? auth()->id(); $chatTitle = 'Wybierz rozmowę'; if ($hasActiveConversation) { if ($activeConversation->type === 'group') { $chatTitle = $activeConversation->name ?: 'Grupa #' . $activeConversation->id; } else { $other = $activeConversation->participantsUsers ->firstWhere('id', '!=', $currentId); $chatTitle = $other->name ?? 'Rozmowa #' . $activeConversation->id; } } // ostatnie ID wiadomości (albo 0 gdy brak) $lastMessageId = ($messages ?? collect())->last()->id ?? 0; @endphp