{{-- 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
{{-- Header --}}
{{ $isEmail ? __('Email') : __('SMS') }} @if($hasAutomation) {{ __('Automation') }} @endif @if(!$isSent) {{ __('Scheduled') }} @endif
@if($title) {{ Str::limit($title, 80) }} @else {{ Str::limit(strip_tags($content), 80) }} @endif
{{ __('To') }}: {{ $recipientName }} @if($isEmail && $recipientEmail) {{ Str::limit($recipientEmail, 40) }} @elseif(!$isEmail && $recipientPhone) {{ $recipientPhone }} @endif @if($sender) {{ __('By') }}: {{ $sender->fullname ?? $sender->name ?? __('Unknown') }} @endif
@if(auth()->user()->is_admin_manager && ($ip = $item->ip ?? data_get($item, 'properties.ip'))) {{ $ip }} @endif {{ $date->format('d/m/y') }} {{ $date->format('H:i') }}
{{ __('Show preview') }} @if($isSentEmail) @else @endif
@if($isEmail) {!! Str::limit(strip_tags($content), 500) !!} @else {{ Str::limit($content, 500) }} @endif