check()) { return; } $userId = auth()->id(); // Últimas conversaciones con mensajes no leídos $unreadConversations = Message::where('receiver_id', $userId) ->whereNull('read_at') ->with('sender') ->orderBy('created_at', 'desc') ->get() ->unique('user_id') ->take(5); $unreadMessagesCount = Message::where('receiver_id', $userId) ->whereNull('read_at') ->count(); // Notificaciones no leídas $unreadNotifications = auth()->user() ->unreadNotifications() ->latest() ->take(5) ->get(); $unreadNotificationsCount = auth()->user()->unreadNotifications()->count(); $view->with([ 'headerUnreadConversations' => $unreadConversations, 'headerUnreadMessagesCount' => $unreadMessagesCount, 'headerUnreadNotifications' => $unreadNotifications, 'headerUnreadNotificationsCount' => $unreadNotificationsCount, ]); } }