{{-- Notification Item - Professional Card Design --}} {{-- Handles both SentNotification ($notification) and SentEmail ($email) models --}} @php // Normalize data for both SentNotification and SentEmail models $isSentEmail = isset($email); $item = $isSentEmail ? $email : ($notification ?? null); if (!$item) return; $isEmail = $isSentEmail || ($item->notification_type ?? null) === 'email'; $color = $isEmail ? 'info' : 'success'; $iconName = $isEmail ? 'mail' : 'chat'; // Determine if sent (SentEmail is always sent, SentNotification checks sent_at) $isSent = $isSentEmail || (bool) ($item->sent_at ?? false); // Get title/subject $title = $isSentEmail ? $item->subject : ($item->title ?? null); $content = $isSentEmail ? $item->body : ($item->content ?? ''); // Get recipient info if ($isSentEmail) { $recipientName = $item->receiver?->name ?? $item->receiver?->fullname ?? $item->to ?? __('Unknown'); $recipientEmail = $item->to; $recipientPhone = null; } else { $recipientName = $item->receiver?->name ?? $item->receiver?->fullname ?? __('Unknown'); $recipientEmail = $item->receiver?->email ?? null; $recipientPhone = $item->receiver?->phone_mobile ?? null; } // Get sender info $sender = $isSentEmail ? $item->user : ($item->user ?? null); // Get date $date = $isSentEmail ? $item->created_at : ($item->sent_at ?? $item->created_at); // Has automation $hasAutomation = !$isSentEmail && ($item->notificationAutomation ?? null); // Unique key $itemKey = $isSentEmail ? "sent-email-{$item->id}" : "notification-{$item->id}"; @endphp