@push('css') @endpush {{-- detials log section for all, email , notes , test and call logs --}} @use('Carbon\Carbon', 'Carbon') @php $badgeClasses = ['primary', 'info', 'danger', 'success', 'warning']; @endphp {{--

Records

--}}

Records

@php $sections = [ 'notes' => 'Notes', 'emails' => 'Emails', 'texts' => 'Texts', 'call_logs' => 'Log Call', ]; $communications = collect(); foreach (['notes', 'emails', 'texts', 'call_logs'] as $type) { if (!empty($contact[$type])) { foreach ($contact[$type] as $item) { $item['type'] = $type; $communications->push($item); } } } $communications = $communications->sortByDesc('created_at'); // Define colors for each type $bgColors = [ 'notes' => 'bg-info-subtle', 'emails' => 'bg-warning-subtle', 'texts' => 'bg-success-subtle', 'call_logs' => 'bg-primary-subtle', ]; @endphp
@if (!empty($contact['contact_notes']) || count($communications) > 0) @forelse ($communications as $comm) @php $createdDate = Carbon::parse($comm['created_at']); $iconClass = [ 'notes' => 'bi bi-journal-text text-primary', 'emails' => 'fa-solid fa-envelope text-primary', 'texts' => 'fa-solid fa-comment-dots text-success', 'call_logs' => 'fa-solid fa-phone text-danger', ][$comm['type']]; $bgColor = $bgColors[$comm['type']]; @endphp
  • {{ $createdDate->diffForHumans() }} {{ str_replace('-', ' ', ucfirst(session('username'))) }} {{ $createdDate->format('d/m/Y') }}
    @if ($comm['type'] === 'emails')

    To: {{ $comm['to_email'] ?? '' }}

    @if (!empty($comm['cc_emails']))

    CC: @foreach (explode(',', $comm['cc_emails']) as $cc_email) {{ trim($cc_email) }} @endforeach

    @endif

    Subject: {!! $comm['subject'] ?? 'No Subject' !!}

    Message: {!! $comm['message'] ?? 'No Message' !!}

    @elseif ($comm['type'] === 'notes' || $comm['type'] === 'texts' || $comm['type'] === 'call_logs')
    {!! $comm['note'] ?? '' !!}
    @endif
  • @empty @endforelse @if (!empty($contact['contact_notes']))
  • @endif @else

    No Data Found

    @endif
    @foreach ($sections as $key => $label) @switch($key) @case('notes') @php $hasNotes = !empty($contact[$key]) || !empty($contact['contact_notes']); @endphp @if ($hasNotes) @if (!empty($contact['contact_notes']))
  • {{ Carbon::parse($contact['created_at'])->diffForHumans() }} {{ str_replace('-', ' ', ucfirst(session('username'))) }} {{ Carbon::parse($contact['created_at'])->format('d/m/Y') }}
    {!! $contact['contact_notes'] !!}
  • @endif @foreach (array_reverse($contact[$key] ?? []) as $note) @php $badgeClass = $badgeClasses[$note['id'] % count($badgeClasses)]; $createdDate = Carbon::parse($note['created_at']); @endphp
  • {{ $createdDate->diffForHumans() }} {{ str_replace('-', ' ', ucfirst(session('username'))) }} {{ $createdDate->format('d/m/Y') }}
    {!! $note['note'] ?? '' !!}
  • @endforeach @else

    {{ $label }} Not Found

    @endif
    @break @case('emails') @if (isset($contact[$key])) @forelse (array_reverse($contact[$key]) as $email) @php $badgeClass = $badgeClasses[$email['id'] % count($badgeClasses)]; $createdDate = Carbon::parse($email['created_at']); // Extract to_email $toEmail = $email['to_email'] ?? ''; // Remove to_email from cc_emails list $ccEmails = collect(explode(',', $email['cc_emails'] ?? '')) ->map(fn($cc) => trim($cc)) ->reject(fn($cc) => $cc === $toEmail) // Remove to_email from CC ->toArray(); @endphp
  • {{ $createdDate->diffForHumans() }} {{ str_replace('-', ' ', ucfirst(session('username'))) }} {{ $createdDate->format('d/m/Y') }}
  • @empty

    {{ $label }} Not Found

    @endforelse @else

    {{ $label }} Not Found

    @endif
    @break @case('texts') @if (isset($contact[$key])) @forelse (array_reverse($contact[$key]) as $text) @php $badgeClass = $badgeClasses[$note['id'] % count($badgeClasses)]; $createdDate = Carbon::parse($note['created_at']); @endphp
  • {{ $createdDate->diffForHumans() }} {{ str_replace('-', ' ', ucfirst(session('username'))) }} {{ $createdDate->format('d/m/Y') }}
    {!! $note['note'] ?? '' !!}
  • @empty

    {{ $label }} Not Found

    @endforelse @else

    {{ $label }} Not Found

    @endif
    @break @case('call_logs') @if (isset($contact[$key])) @forelse (array_reverse($contact[$key]) as $logs) @php $badgeClass = $badgeClasses[ $logs['id'] % count($badgeClasses) ]; $createdDate = Carbon::parse($logs['created_at']); @endphp
  • {{ $createdDate->diffForHumans() }} {{ str_replace('-', ' ', ucfirst(session('username'))) }} {{ $createdDate->format('d/m/Y') }}
    {!! $note['note'] ?? '' !!}
  • @empty

    {{ $label }} Not Found

    @endforelse @else

    {{ $label }} Not Found

    @endif
    @break @default @endswitch @endforeach