{{-- resources/views/agent/leads/partials/purchased-health.blade.php --}}
Purchased Health Leads
Purchase More Leads
@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
@foreach ($rows as $lead) {{-- Insurance Type (inline + used for conversion) --}} {{-- Purchase Date --}} {{-- Status (inline editable) --}} {{-- Actions placeholder (archive/delete can go here later) --}} @endforeach
Lead Name Phone Email City Insurance Type Purchase Date Status Actions
{{ trim(($lead->first_name ?? '') . ' ' . ($lead->last_name ?? '')) }} {{ $lead->phone_number ?? '—' }} {{ $lead->email ?? '—' }} {{ $lead->city ?? '—' }}
@csrf
@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
{{-- Inline update script: saves insurance_type & status via PATCH --}} @endif