@php // Combine all records into a single collection $allNotes = collect(); $lead->recordings->each(function ($recording) use ($allNotes) { $allNotes->push([ 'type' => 'recording', 'data' => $recording, 'created_at' => $recording->start_datetime, ]); }); $lead->emails->each(function ($email) use ($allNotes) { $allNotes->push([ 'type' => 'email', 'data' => $email, 'created_at' => $email->created_at, ]); }); $lead->leadSMS->each(function ($sms) use ($allNotes) { $allNotes->push([ 'type' => 'sms', 'data' => $sms, 'created_at' => $sms->created_at, ]); }); $lead->leadWhatsappSMS->each(function ($sms) use ($allNotes) { $allNotes->push([ 'type' => 'whatsapp', 'data' => $sms, 'created_at' => $sms->created_at, ]); }); $sortedNotes = $allNotes->sortByDesc('created_at'); @endphp @if ($sortedNotes->count() > 0)
@foreach ($sortedNotes as $note)
@if ($note['type'] === 'email') @if($note['data']->is_received === 1) Email Received @else Email Sent @endif on @elseif ($note['type'] === 'sms') SMS sent on @elseif ($note['type'] === 'whatsapp') WhatsApp sent on @elseif ($note['type'] === 'recording') Inbound call on @endif {{ \Carbon\Carbon::parse($note['created_at'])->format('d M Y h:i A') }}
@if($note['type'] === 'recording' && $note['data']->audio_file_location)
@elseif($note['type'] === 'email')

{{ $note['data']->subject }}

{!! wrapQuotedSections($note['data']->body) !!}

@elseif($note['type'] === 'sms' || $note['type'] === 'whatsapp')

{{ $note['data']->message }}

@endif
@endforeach
@endif