@extends('layouts.app') @section('content')

Mes notifications

@if($notifications->count() > 0) {{ $notifications->total() }} notification{{ $notifications->total() > 1 ? 's' : '' }} au total @else Restez informé de toutes vos activités @endif

@if($notifications->where('read_at', null)->count() > 0)
@csrf
@endif
@if(session('success'))

{{ session('success') }}

@endif @if(session('error'))

{{ session('error') }}

@endif @if($notifications->count() > 0)
@foreach($notifications as $notification) @php // Determine notification type and apply appropriate colors $isEquipmentNotification = strpos($notification->type, 'Equipment') !== false; $isServiceNotification = strpos($notification->type, 'Booking') !== false; // Set the appropriate colors for the entire card if ($isEquipmentNotification) { // Equipment notifications - green theme $cardBgClass = 'bg-green-50'; $borderClass = 'border-l-green-500'; $textPrimaryClass = 'text-green-900'; $textSecondaryClass = 'text-green-700'; $textTertiaryClass = 'text-green-600'; $linkClass = 'text-green-600 hover:text-green-800'; $newBadgeBgClass = 'bg-green-100'; $newBadgeTextClass = 'text-green-800'; $newBadgeDotClass = 'bg-green-500'; } elseif ($isServiceNotification) { // Service/Booking notifications - blue theme $cardBgClass = 'bg-blue-50'; $borderClass = 'border-l-blue-500'; $textPrimaryClass = 'text-blue-900'; $textSecondaryClass = 'text-blue-700'; $textTertiaryClass = 'text-blue-600'; $linkClass = 'text-blue-600 hover:text-blue-800'; $newBadgeBgClass = 'bg-blue-100'; $newBadgeTextClass = 'text-blue-800'; $newBadgeDotClass = 'bg-blue-500'; } else { // Default theme - blue theme $cardBgClass = 'bg-blue-50'; $borderClass = 'border-l-blue-500'; $textPrimaryClass = 'text-blue-900'; $textSecondaryClass = 'text-blue-700'; $textTertiaryClass = 'text-blue-600'; $linkClass = 'text-blue-600 hover:text-blue-800'; $newBadgeBgClass = 'bg-blue-100'; $newBadgeTextClass = 'text-blue-800'; $newBadgeDotClass = 'bg-blue-500'; } @endphp @php // Préparation de l'URL d'action pour la notification $notifActionUrl = null; if (is_array($notification->data)) { $notifActionUrl = $notification->data['url'] ?? $notification->data['action_url'] ?? null; } elseif (is_string($notification->data)) { $decodedData = json_decode($notification->data, true); $notifActionUrl = $decodedData['url'] ?? $decodedData['action_url'] ?? null; } $redirectUrl = $notifActionUrl ? route('notifications.redirect', $notification->id) : null; @endphp
@php // Set the appropriate icon and colors 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 icons for other notifications $iconConfig = [ 'App\\Notifications\\NewOfferNotification' => ['icon' => 'fa-handshake', 'color' => 'text-blue-500', 'bg' => 'bg-blue-100'], 'App\\Notifications\\OfferAcceptedNotification' => ['icon' => 'fa-check-circle', 'color' => 'text-green-500', 'bg' => 'bg-green-100'], 'App\\Notifications\\OfferRejectedNotification' => ['icon' => 'fa-times-circle', 'color' => 'text-red-500', 'bg' => 'bg-red-100'], 'App\\Notifications\\BookingCancelledNotification' => ['icon' => 'fa-calendar-times', 'color' => 'text-orange-500', 'bg' => 'bg-orange-100'], 'App\\Notifications\\BookingConfirmedNotification' => ['icon' => 'fa-calendar-check', 'color' => 'text-green-500', 'bg' => 'bg-green-100'], 'App\\Notifications\\BookingRejectedNotification' => ['icon' => 'fa-calendar-times', 'color' => 'text-red-500', 'bg' => 'bg-red-100'], 'App\\Notifications\\EquipmentRentalAcceptedNotification' => ['icon' => 'fa-tools', 'color' => 'text-green-500', 'bg' => 'bg-green-100'], 'App\\Notifications\\EquipmentRentalRejectedNotification' => ['icon' => 'fa-tools', 'color' => 'text-red-500', 'bg' => 'bg-red-100'], 'App\\Notifications\\EquipmentRentalResponseNotification' => ['icon' => 'fa-reply', 'color' => 'text-blue-500', 'bg' => 'bg-blue-100'], 'App\\Notifications\\MissionCompletedNotification' => ['icon' => 'fa-trophy', 'color' => 'text-yellow-500', 'bg' => 'bg-yellow-100'], 'App\\Notifications\\NewReviewNotification' => ['icon' => 'fa-star', 'color' => 'text-purple-500', 'bg' => 'bg-purple-100'], 'App\\Notifications\\PrestataireApprovedNotification' => ['icon' => 'fa-user-check', 'color' => 'text-green-500', 'bg' => 'bg-green-100'], 'App\\Notifications\\RequestHasOffersNotification' => ['icon' => 'fa-envelope', 'color' => 'text-blue-500', 'bg' => 'bg-blue-100'], 'App\\Notifications\\NewMessageNotification' => ['icon' => 'fa-comment', 'color' => 'text-purple-500', 'bg' => 'bg-purple-100'], 'App\\Notifications\\AnnouncementStatusNotification' => ['icon' => 'fa-bullhorn', 'color' => 'text-indigo-500', 'bg' => 'bg-indigo-100'], ]; $config = $iconConfig[$notification->type] ?? ['icon' => 'fa-bell', 'color' => 'text-gray-500', 'bg' => 'bg-gray-100']; $iconClass = $config['icon']; $colorClass = $config['color']; $bgClass = $config['bg']; } @endphp
@if(!$notification->read_at) Nouveau @endif

@php // Try different approaches to get the title $title = null; // Method 1: Direct accessor if it exists if (method_exists($notification, 'getTitleAttribute')) { $title = $notification->title; } // Method 2: From data if it's an array if (empty($title) && is_array($notification->data)) { $title = $notification->data['title'] ?? null; } // Method 3: From decoded JSON if it's a string if (empty($title) && is_string($notification->data)) { $decodedData = json_decode($notification->data, true); $title = $decodedData['title'] ?? null; } // Fallback title if (empty($title)) { $notificationType = class_basename($notification->type); $title = str_replace('Notification', '', $notificationType); $title = preg_replace('/(?

@php // Try to get client name from notification data $clientName = null; // Method 1: From data if it's an array if (is_array($notification->data)) { $clientName = $notification->data['client_name'] ?? null; } // Method 2: From decoded JSON if it's a string if (empty($clientName) && is_string($notification->data)) { $decodedData = json_decode($notification->data, true); $clientName = $decodedData['client_name'] ?? null; } @endphp @if(!empty($clientName) && ($isEquipmentNotification || $isServiceNotification))
{{ $clientName }}
@endif

@php // Try different approaches to get the message $message = null; // Method 1: Direct accessor if it exists if (method_exists($notification, 'getMessageAttribute')) { $message = $notification->message; } // Method 2: From data if it's an array if (empty($message) && is_array($notification->data)) { $message = $notification->data['message'] ?? null; } // Method 3: From decoded JSON if it's a string if (empty($message) && is_string($notification->data)) { $decodedData = json_decode($notification->data, true); $message = $decodedData['message'] ?? null; } // Fallback message if (empty($message)) { $message = 'Vous avez reçu une notification.'; } @endphp {{ $message }}

@php // Try to get action URL from various sources $actionUrl = null; // Method 1: Direct accessor if it exists if (method_exists($notification, 'getActionUrlAttribute')) { $actionUrl = $notification->action_url; } // Method 2: From data if it's an array if (empty($actionUrl) && is_array($notification->data)) { $actionUrl = $notification->data['url'] ?? $notification->data['action_url'] ?? null; } // Method 3: From decoded JSON if it's a string if (empty($actionUrl) && is_string($notification->data)) { $decodedData = json_decode($notification->data, true); $actionUrl = $decodedData['url'] ?? $decodedData['action_url'] ?? null; } @endphp @if(!empty($actionUrl)) {{ $notification->action_text ?? 'Voir les détails' }} → @endif
{{ $notification->created_at->diffForHumans() }}
@if(!$notification->read_at)
@csrf
@endif
@endforeach
@if($notifications->hasPages())
{{ $notifications->links() }}
@endif @else

Vous êtes à jour !

Aucune nouvelle notification pour le moment. Nous vous tiendrons informé de toutes vos activités importantes.

@if(Auth::user()->hasRole('client')) Nouvelle demande @elseif(Auth::user()->hasRole('prestataire')) Voir les demandes @endif Retour à l'accueil
@endif
@endsection