@extends('layouts.admin') @section('title', 'Lead Details') @section('content') @php $leadType = $lead->module_type ?? $lead->service?->type ?? ($lead->listing?->service?->type ?? null); $typeLabels = [ 'property' => ['label' => 'Property', 'icon' => 'bi-building', 'route' => 'admin.properties.show', 'param' => 'property'], 'job' => ['label' => 'Job', 'icon' => 'bi-briefcase', 'route' => 'admin.jobs.show', 'param' => 'job'], 'education' => ['label' => 'Education', 'icon' => 'bi-mortarboard', 'route' => 'admin.educations.show', 'param' => 'education'], 'service' => ['label' => 'Service', 'icon' => 'bi-wrench-adjustable-circle', 'route' => 'admin.services.show', 'param' => 'localService'], 'service_category' => ['label' => 'Service Category', 'icon' => 'bi-tags', 'route' => 'web.services.category.show', 'param' => 'serviceCategory'], 'contact' => ['label' => 'Contact', 'icon' => 'bi-envelope-open', 'route' => null, 'param' => null], ]; $typeInfo = $typeLabels[$leadType] ?? null; $canManage = auth()->user()?->hasPermission('leads', 'manage'); $linkedModule = $lead->module ?? $lead->listing; $linkedTitle = $linkedModule?->name ?? $linkedModule?->title ?? $lead->service?->title; $linkedLocation = $lead->location ?: ($linkedModule?->location ?? null); $backType = $leadType === 'service_category' ? 'service' : $leadType; @endphp

Lead Details

Review lead information and respond to the customer

@if($typeInfo) {{ $typeInfo['label'] }} @endif {{ ucfirst(str_replace('_', ' ', $lead->status)) }}
Customer
Name: {{ $lead->name }}
@if($lead->user)
Registered User: {{ $lead->user->name }}
User Email: {{ $lead->user->email ?: '-' }}
@endif
Location: {{ $linkedLocation ?: '-' }}
Created: {{ $lead->created_at?->format('d M Y h:i A') }}

Message
@if($leadType === 'job') @php $messageData = json_decode($lead->message, true); @endphp @if(is_array($messageData))

Job Track: {{ $messageData['job_track'] ?? '—' }}

Category: {{ $messageData['category'] ?? '—' }}

Education: {{ $messageData['education'] ?? '—' }}

Work Experience: {{ $messageData['work_experience'] ?? '—' }}

Resume: @if(! empty($messageData['resume'])) View @else — @endif

@else

{{ $lead->message ?: '—' }}

@endif @elseif($leadType === 'education') @php $messageData = json_decode($lead->message, true); @endphp @if(is_array($messageData))

Program Context: {{ $messageData['program_context'] ?? '—' }}

Education Level: {{ $messageData['study_level'] ?? '—' }}

Field of Study: {{ $messageData['field_of_study'] ?? '—' }}

Preferred Destination: {{ $messageData['preferred_destination'] ?? '—' }}

Additional Notes: {{ $messageData['additional_notes'] ?? '—' }}

@else

{{ $lead->message ?: '—' }}

@endif @else

{{ $lead->message ?: '—' }}

@endif
@if($typeInfo) Linked {{ $typeInfo['label'] }} @else Linked Listing @endif
@if($linkedModule)

{{ $linkedTitle }}

{{ $linkedLocation ?: '-' }}

@if($leadType === 'service_category')

Category: {{ $linkedTitle }}

@else

Service: {{ $lead->service?->title ?? '-' }}

@endif @if($typeInfo && ! empty($typeInfo['route'])) Open {{ $typeInfo['label'] }} @endif
@else

This lead isn't attached to any listing — it was submitted via the general {{ $lead->service?->title ?? 'enquiry' }} form.

@endif
@if($canManage)
Update Status
@csrf @method('PUT') Call {{ $lead->mobile }} @if($lead->user?->whatsapp_number || $lead->mobile) WhatsApp @endif
@endif
Back to {{ $leadType === 'service_category' ? 'Service' : ($typeInfo['label'] ?? 'All') }} Leads
@endsection