{{-- 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; $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; $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; $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