@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() }}