{{-- resources/views/layouts/navigation.blade.php --}} @php use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; $user = Auth::user(); // Routes optionnelles : on teste leur existence pour éviter les 500 (RouteNotFoundException) $homeRoute = Route::has('home') ? route('home') : url('/'); $servicesRoute = Route::has('services.index') ? route('services.index') : null; $equipmentRoute = Route::has('equipment.index') ? route('equipment.index') : null; $urgentSalesRoute = Route::has('urgent-sales.index') ? route('urgent-sales.index') : null; $videosFeedRoute = Route::has('videos.feed') ? route('videos.feed') : null; $foodExploreRoute = Route::has('food.explore') ? route('food.explore') : null; $messagingRoute = Route::has('messaging.index') ? route('messaging.index') : null; $notificationsIndex = Route::has('notifications.index') ? route('notifications.index') : null; $notificationsMarkAll = Route::has('notifications.mark-all-read') ? route('notifications.mark-all-read') : null; $clientDashboardRoute = Route::has('client.dashboard') ? route('client.dashboard') : null; $prestataireDashboardRoute = Route::has('prestataire.dashboard') ? route('prestataire.dashboard') : null; $defaultDashboardRoute = Route::has('dashboard') ? route('dashboard') : null; $prestataireAgendaRoute = Route::has('prestataire.agenda.index') ? route('prestataire.agenda.index') : null; $prestataireServicesIndex = Route::has('prestataire.services.index') ? route('prestataire.services.index') : null; $prestataireServicesCreate = Route::has('prestataire.services.create')? route('prestataire.services.create') : null; $prestataireEquipmentIndex = Route::has('prestataire.equipment.index')? route('prestataire.equipment.index') : null; $prestataireEquipmentCreate = Route::has('prestataire.equipment.create')? route('prestataire.equipment.create'): null; $prestataireUrgentSalesIndex = Route::has('prestataire.urgent-sales.index') ? route('prestataire.urgent-sales.index') : null; $prestataireUrgentSalesCreate = Route::has('prestataire.urgent-sales.create') ? route('prestataire.urgent-sales.create') : null; $prestataireVideosManage = Route::has('prestataire.videos.manage') ? route('prestataire.videos.manage') : null; $clientBookingsRoute = Route::has('client.bookings.index') ? route('client.bookings.index') : null; $clientBookingsHistoryRoute = Route::has('client.bookings.history') ? route('client.bookings.history') : null; $clientEquipmentRentals = Route::has('client.equipment-rental-requests.index') ? route('client.equipment-rental-requests.index') : null; $clientFollowsRoute = Route::has('client.prestataire-follows.index') ? route('client.prestataire-follows.index') : null; $clientCartRoute = Route::has('client.cart.index') ? route('client.cart.index') : null; // Nouvelles fonctionnalités client $clientPaymentsRoute = Route::has('client.payments.index') ? route('client.payments.index') : null; $clientSubscriptionsRoute = Route::has('client.subscriptions.index') ? route('client.subscriptions.index') : null; $clientAuctionsRoute = Route::has('client.auctions.index') ? route('client.auctions.index') : null; $clientDeliveryRoute = Route::has('client.delivery.index') ? route('client.delivery.index') : null; $clientAddressBookRoute = Route::has('client.address-book.index') ? route('client.address-book.index') : null; $clientNotificationSettingsRoute = Route::has('client.notification-settings.index') ? route('client.notification-settings.index') : null; // Nouvelles fonctionnalités prestataire $prestataireBookingsRoute = Route::has('prestataire.bookings.index') ? route('prestataire.bookings.index') : null; $prestataireBookingsHistoryRoute = Route::has('prestataire.bookings.history') ? route('prestataire.bookings.history') : null; $prestatairePaymentsRoute = Route::has('prestataire.payments.index') ? route('prestataire.payments.index') : null; $prestataireSubscriptionsRoute = Route::has('prestataire.subscriptions.index') ? route('prestataire.subscriptions.index') : null; $prestataireAuctionsRoute = Route::has('prestataire.auctions.index') ? route('prestataire.auctions.index') : null; $prestataireDeliveryRoute = Route::has('prestataire.delivery.index') ? route('prestataire.delivery.index') : null; $prestataireInventoryRoute = Route::has('prestataire.inventory.index') ? route('prestataire.inventory.index') : null; $prestataireAddressBookRoute = Route::has('prestataire.address-book.index') ? route('prestataire.address-book.index') : null; $prestataireNotificationSettingsRoute = Route::has('prestataire.notification-settings.index') ? route('prestataire.notification-settings.index') : null; $profileEditRoute = Route::has('profile.edit') ? route('profile.edit') : null; $profileSettingsRoute = Route::has('profile.settings') ? route('profile.settings') : null; $loginRoute = Route::has('login') ? route('login') : null; $registerRoute = Route::has('register') ? route('register') : null; $logoutRoute = Route::has('logout') ? route('logout') : null; // Compteurs sécurisés (try/catch pour éviter les erreurs de relations / tables) $unreadMessagesCount = 0; $unreadNotificationsCount = 0; $recentNotifications = collect(); if ($user) { try { if (method_exists($user, 'receivedMessages')) { $unreadMessagesCount = $user->receivedMessages()->whereNull('read_at')->count(); } } catch (\Throwable $e) { $unreadMessagesCount = 0; } try { if (method_exists($user, 'notifications')) { $unreadNotificationsCount = $user->notifications()->whereNull('read_at')->count(); $recentNotifications = $user->notifications() ->whereNull('read_at') ->orderBy('created_at', 'desc') ->limit(3) ->get(); } } catch (\Throwable $e) { $unreadNotificationsCount = 0; $recentNotifications = collect(); } } @endphp @once @endonce