@php $unreadCount = Auth::user()->notifications()->whereNull('read_at')->count(); $recentNotifications = Auth::user()->notifications() ->whereNull('read_at') ->orderBy('created_at', 'desc') ->limit(5) ->get(); @endphp

Notifications

@if($unreadCount > 0)
@csrf
@endif
@if($recentNotifications->isEmpty())

Aucune nouvelle notification

@else
@foreach($recentNotifications as $notification) @php // Determine notification type and apply appropriate icon/colors $isEquipmentNotification = strpos($notification->type, 'Equipment') !== false; $isServiceNotification = strpos($notification->type, 'Booking') !== false; if ($isEquipmentNotification) { // Equipment notifications - green color and tools icon $iconClass = 'fa-tools'; $colorClass = 'text-green-500'; $bgClass = 'bg-green-100'; } elseif ($isServiceNotification) { // Service/Booking notifications - blue color and cogs icon $iconClass = 'fa-cogs'; $colorClass = 'text-blue-500'; $bgClass = 'bg-blue-100'; } else { // Default styling for other notifications $iconClass = 'fa-bell'; $colorClass = 'text-blue-600'; $bgClass = 'bg-blue-100'; } $data = is_array($notification->data) ? $notification->data : json_decode($notification->data, true); $title = $data['title'] ?? 'Notification'; $message = $data['message'] ?? ''; // Use redirect route to mark as read and redirect in one click $url = route('notifications.redirect', $notification->id); @endphp

{{ $title }}

{{ $message }}

{{ $notification->created_at->diffForHumans() }}

@endforeach
@endif