@include('Partials.sidebar')
@include('Partials.header')

{{ $pageTitle }} @if($myLeads) — assigned to me @endif

@if($myLeads) Your personal lead pipeline @else All leads across the team @endif

New Lead
  1. {{ $pageTitle }}
@foreach(['success', 'error'] as $t) @if(session($t))
{{ session($t) }}
@endif @endforeach {{-- Pipeline stat cards --}}
@foreach(\App\Models\Lead::STATUSES as $key => $cfg) @php $count = $stats[$key] ?? 0; @endphp @endforeach
{{-- Filters --}}
@if(session('admin_role') === 'super_admin') @endif @if($myLeads) All Leads @endif
{{-- Leads table --}}
{{ $leads->total() }} Leads
@forelse($leads as $lead) @php $sc = $lead->statusConfig(); $src = $lead->sourceConfig(); @endphp @empty @endforelse
Lead Source Interested In Budget Status Assigned Last Activity Actions
{{ $lead->name }}
{{ $lead->phone }}
@if($lead->email)
{{ $lead->email }}
@endif
{{ $src['icon'] }} {{ $src['label'] }} {{ $lead->interested_in ?: '—' }} {{ $lead->budgetRange($currency) }} {{ $sc['label'] }} @if($lead->latestFollowUp)
{{ $lead->latestFollowUp->typeConfig()['icon'] }} {{ $lead->latestFollowUp->created_at->diffForHumans() }}
@endif
{{ $lead->assignedAgent?->name ?? '—' }} {{ $lead->last_contacted_at ? $lead->last_contacted_at->diffForHumans() : $lead->created_at->diffForHumans() }}
@if(!$lead->isWon() && $lead->email) @endif
No leads found. Create one →
@if($leads->hasPages()) @endif
{{-- ── API Integration Panel (super_admin only) ──────────────── --}} @if(session('admin_role') === 'super_admin')
Landing Page API Integration Click to expand — give this to your developer
{{-- Endpoint + Key --}}
POST — accepts JSON body
{{-- Fields table --}}
@foreach([ ['name', 'string', '✅ Yes', 'Full name of the enquirer'], ['phone', 'string', '✅ Yes', 'Phone number (without country code)'], ['country_code', 'string', 'No', 'Default +91. e.g. +971, +44'], ['email', 'string', 'No', 'Email address'], ['interested_in', 'string', 'No', 'e.g. Villa, Apartment, Plot'], ['budget_min', 'number', 'No', 'Min budget in numbers (e.g. 5000000)'], ['budget_max', 'number', 'No', 'Max budget in numbers'], ['preferred_contact_time', 'string', 'No', 'e.g. Morning, After 6PM'], ['notes', 'string', 'No', 'Message from the lead'], ['utm_source', 'string', 'No', 'e.g. facebook, google, instagram'], ['utm_medium', 'string', 'No', 'e.g. cpc, email, banner'], ['utm_campaign', 'string', 'No', 'Campaign name'], ['utm_content', 'string', 'No', 'Ad variant / creative name'], ['landing_page', 'string', 'No', 'Identifier for the page (e.g. villa-launch)'], ] as [$f,$t,$r,$d]) @endforeach
Field Type Required Description
{{ $f }} {{ $t }} {{ $r }} {{ $d }}
{{-- Response format --}}
{
  "success": true,
  "message": "Thank you! We will contact you shortly."
}
{
  "error": "Unauthorized."
}

// 429 - Too many attempts:
{
  "error": "Too many submissions. Try again in 45 seconds."
}
{{-- Code tabs --}}
async function submitLead(data) {
  const res = await fetch('{{ url('/api/landing/lead') }}', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'X-Landing-Key': 'YOUR_API_KEY_HERE',
    },
    body: JSON.stringify({
      name:                   data.name,           // required
      phone:                  data.phone,          // required
      country_code:           '+91',
      email:                  data.email,
      interested_in:          data.interested_in,
      preferred_contact_time: data.contact_time,
      notes:                  data.message,
      utm_source:   new URLSearchParams(location.search).get('utm_source'),
      utm_medium:   new URLSearchParams(location.search).get('utm_medium'),
      utm_campaign: new URLSearchParams(location.search).get('utm_campaign'),
      landing_page: 'your-page-name-here',
    }),
  });
  const json = await res.json();
  if (res.ok) alert(json.message);
}
{{-- /code tabs --}}
{{-- /card-body --}}
{{-- /collapse --}}
@endif
@include('Partials.footer')