@php
use Illuminate\Support\Carbon;
// Fallbacks if controller didn't pass them
$healthInsuranceTypes = $healthInsuranceTypes ?? [
'medicare' => 'Medicare',
'dental' => 'Dental',
];
$statuses = $statuses ?? [
'new' => 'New',
'contacted' => 'Contacted',
'follow_up' => 'Follow Up',
'appointment_set' => 'Appointment Set',
'sold' => 'Sold',
'not_interested' => 'Not Interested',
'dead' => 'Dead',
];
// Ensure we have a collection
$rows = collect($purchasedHealthLeads ?? []);
// Newest purchase first
$rows = $rows->sortByDesc(function ($r) {
$d = $r->purchase_date ?? null;
$dt = $d instanceof \Carbon\CarbonInterface ? $d : ($d ? Carbon::parse($d) : null);
return $dt ? $dt->timestamp : 0;
});
@endphp
@if ($rows->isEmpty())
You haven't purchased any Health leads yet.
@else
Lead Name |
Phone |
Email |
City |
Insurance Type |
Purchase Date |
Status |
Actions |
@foreach ($rows as $lead)
{{ trim(($lead->first_name ?? '') . ' ' . ($lead->last_name ?? '')) }} |
{{ $lead->phone_number ?? '—' }} |
{{ $lead->email ?? '—' }} |
{{ $lead->city ?? '—' }} |
{{-- Insurance Type (inline + used for conversion) --}}
|
{{-- Purchase Date --}}
@if (!empty($lead->purchase_date))
{{ $lead->purchase_date instanceof \Carbon\CarbonInterface
? $lead->purchase_date->format('M d, Y')
: \Illuminate\Support\Carbon::parse($lead->purchase_date)->format('M d, Y') }}
@else
—
@endif
|
{{-- Status (inline editable) --}}
|
{{-- Actions placeholder (archive/delete can go here later) --}}
|
@endforeach
{{-- Inline update script: saves insurance_type & status via PATCH --}}
@endif