@extends('layouts.app') @section('title', 'Lead — ' . ($lead->requirement ? $lead->requirement->title : 'Detail')) @section('page-title', 'Lead Detail') @push('styles') @endpush @section('content') @php $req = $lead->requirement; $client = $req ? $req->client : null; $shortlisted = $lead->shortlistedProperties; $removalReasons = \App\Models\PropertyShortlist::REMOVAL_REASONS; $siteVisits = $lead->siteVisits; $pendingReminders = $lead->reminders->where('is_done', false); $quotes = $lead->quotes; $agreement = $lead->agreement; $defaultDealType = ($req && $req->interest_type === 'rent') ? 'rental' : 'sale'; $agreementIsExpired = $agreement && $agreement->isActive() && $agreement->isRental() && $agreement->agreement_end_date && $agreement->agreement_end_date->lt(\Carbon\Carbon::today()); @endphp
Back to Leads
@if(! $agreement || ! $agreement->isActive() || $agreementIsExpired) @if($lead->isOpen()) @endif @endif @if($lead->isOpen()) @endif
{{-- Client & Requirement Header --}}
Client
@if($client)
{{ $client->mobile }}{{ $client->email ? ' · ' . $client->email : '' }}
@else @endif
Requirement
@if($req)
{{ $req->title }}
{{ \App\Services\ClientRequirementService::formatBudget($req->min_budget, $req->max_budget) }} @if($req->preferred_location) · {{ $req->preferred_location }} @endif
{{ ucfirst($req->status) }}
@else @endif

Assigned: {{ $lead->assignedTo ? $lead->assignedTo->name : 'Unassigned' }}
Created: {{ $lead->created_at->format('d M Y') }}
Last Activity: {{ $lead->last_activity_at ? $lead->last_activity_at->diffForHumans() : '—' }}
{{-- Stage Progress Bar --}}
Pipeline Progress
@foreach($reachedStages as $stage) @php $isCurrent = $lead->current_stage_id === $stage->id; @endphp
{{ $stage->name }}
@endforeach
@if($lead->currentStage) {{ $lead->currentStage->name }} {{ $lead->days_in_stage }} day{{ $lead->days_in_stage == 1 ? '' : 's' }} in this stage @else No stage assigned @endif
{{-- Stage Transition History --}}
Stage History
@forelse($lead->transitions as $transition) @empty @endforelse
From To Changed By Note Date / Time
@if($transition->fromStage) {{ $transition->fromStage->name }} @else — (Created) @endif {{ $transition->toStage->name }} {{ $transition->changedBy ? $transition->changedBy->name : '—' }} {{ $transition->note }} {{ $transition->created_at->format('d M Y, h:i A') }}
No stage transitions recorded.
{{-- Shortlisted Properties --}}
Shortlisted Properties {{ $shortlisted->count() }}
@if($lead->isOpen()) @endif
@if($lead->isOpen()) {{-- AJAX search panel --}}
No properties found.
Searching…
@endif
@if($shortlisted->isEmpty())
No properties shortlisted yet.
@else
@foreach($shortlisted as $sl) @if(!$sl->property) @else @php $prop = $sl->property; $purposeLabel = \App\Models\Property::LISTING_PURPOSES[$prop->listing_purpose] ?? ucwords(str_replace('_', ' ', $prop->listing_purpose)); $purposeCls = $prop->listing_purpose === 'for_rent' ? 'bg-info bg-opacity-10 text-info' : 'bg-success bg-opacity-10 text-success'; $statusLabels = ['published' => ['bg-success', 'Published'], 'under_review' => ['bg-warning text-dark', 'Under Review'], 'unavailable' => ['bg-secondary', 'Unavailable']]; [$statusCls, $statusLabel] = $statusLabels[$prop->status] ?? ['bg-secondary', ucwords(str_replace('_', ' ', $prop->status))]; $areaStr = $prop->area ? number_format((float) $prop->area, 0) . ' ' . strtoupper($prop->area_unit ?? '') : '—'; $propAvail = in_array($prop->id, $propertiesWithSaleDeals) ? 'sold' : (in_array($prop->id, $propertiesWithActiveRentals) ? 'rented' : 'available'); @endphp @endif @endforeach
Property Type Purpose Area Price Status Added By Added On
Property no longer available {{ optional($sl->shortlistedBy)->name ?? '—' }} {{ $sl->created_at->format('d M Y') }}
{{-- Thumbnail --}}
@if($prop->coverImage) {{ $prop->title }} @else
@endif
@if($prop->trashed()) {{ $prop->title }} @if($prop->city)
{{ $prop->city }}
@endif
@else {{ $prop->title }} @if($prop->city)
{{ $prop->city }}
@endif
@endif
{{ (\App\Models\Property::typeLabels())[$prop->type] ?? $prop->type }} {{ $purposeLabel }} {{ $areaStr }} {{ $prop->formattedPrice() }} {{ $statusLabel }} @if($propAvail === 'sold') Sold @elseif($propAvail === 'rented') Rented @endif {{ optional($sl->shortlistedBy)->name ?? '—' }} {{ $sl->created_at->format('d M Y') }} @if(!$prop->trashed()) @endif @if($lead->isOpen()) @endif
@endif
{{-- Site Visits --}}
Site Visits {{ $siteVisits->count() }}
@if($lead->isOpen()) @endif
@if($siteVisits->isEmpty())
No site visits logged yet.
@else
@foreach($siteVisits as $visit) @endforeach
Property Date & Time Stage at Visit Accompanying Staff Notes Logged By
@if($visit->property && !$visit->property->trashed()) {{ $visit->property->title }} @elseif($visit->property) {{ $visit->property->title }} @else Property no longer available @endif {{ $visit->formattedVisitDateTime() }} @if($visit->stageSnapshot) {{ $visit->stageSnapshot->name }} @else @endif {{ $visit->accompanying_staff }} {{ $visit->notes ?: '—' }} {{ optional($visit->loggedBy)->name ?? '—' }}
@endif
{{-- Active Reminders for this Lead --}} @if($pendingReminders->isNotEmpty())
Active Reminders {{ $pendingReminders->count() }}
@endif {{-- Quotes --}}
Quotes {{ $quotes->count() }}
@if($quotes->isEmpty())
No quotes logged yet.
@else
@foreach($quotes as $quote) @endforeach
Property Quoted Price Date Shared By Notes Logged By
{{ optional($quote->property)->title ?? '—' }} ₹ {{ number_format((float)$quote->quoted_price, 0) }} {{ $quote->quote_date ? $quote->quote_date->format('d M Y, H:i') : '—' }} {{ $quote->shared_by }} {{ $quote->notes ?: '—' }} {{ optional($quote->createdBy)->name ?? '—' }}
@endif
{{-- Final Deal --}}
Final Deal
@if(! $agreement || ! $agreement->isActive() || $agreementIsExpired) @if($lead->isOpen()) @endif @endif @if($agreement && $agreement->isActive() && ! $agreementIsExpired && auth()->user()->isAdmin()) @endif
@if(! $agreement || ! $agreement->isActive() || $agreementIsExpired)
No active deal recorded yet.
@else
Deal Type
{{ $agreement->isRental() ? 'Rental' : 'Sale' }} @if(! $agreement->isActive()) Deactivated @endif
Property
{{ optional($agreement->property)->title ?? '—' }}
Deal Date
{{ $agreement->deal_date ? $agreement->deal_date->format('d M Y') : '—' }}
Client Name
{{ $agreement->client_name }}
Owner Name
{{ $agreement->owner_name }}
Agreed Price
₹ {{ number_format((float)$agreement->agreed_price, 0) }}
@if($agreement->isRental())
Agreement Period
{{ $agreement->agreement_start_date ? $agreement->agreement_start_date->format('d M Y') : '—' }} → {{ $agreement->agreement_end_date ? $agreement->agreement_end_date->format('d M Y') : '—' }}
Monthly Rent
₹ {{ number_format((float)$agreement->monthly_rent, 0) }}
Escalation Clause
{{ $agreement->rent_escalation_clause ?: '—' }}
Agreement Document
@if($agreement->document_path)
{{ $agreement->document_original_name ?? 'agreement.pdf' }} Download @if(auth()->user()->isAdmin() || $lead->assigned_to === auth()->id()) @endif
@else
No document uploaded @if(auth()->user()->isAdmin() || $lead->assigned_to === auth()->id()) @endif
@endif @if(auth()->user()->isAdmin() || $lead->assigned_to === auth()->id())
@csrf @error('agreement_document')
{{ $message }}
@else @enderror
PDF only, max 20 MB
@endif
@endif @if($agreement->notes)
Notes
{{ $agreement->notes }}
@endif @if($agreement->correction_note)
Correction Note: {{ $agreement->correction_note }}
@endif @if(! $agreement->isActive())
Deactivated @if($agreement->deactivated_at) on {{ $agreement->deactivated_at->format('d M Y, H:i') }} @endif @if($agreement->deactivatedBy) by {{ $agreement->deactivatedBy->name }} @endif @if($agreement->deactivation_note) — {{ $agreement->deactivation_note }} @endif
@endif
@if(auth()->user()->isAdmin())
@csrf @method('PATCH') @error('correction_note')
{{ $message }}
@enderror
@endif @endif
{{-- Old Deals (Deactivated / Historical) --}} @if($oldDeals->isNotEmpty())
Old Deals {{ $oldDeals->count() }}
@foreach($oldDeals as $old) @php $oldBadgeCls = $old->isRental() ? 'bg-info bg-opacity-75' : 'bg-success bg-opacity-75'; $oldBadgeTxt = $old->isRental() ? 'Rental' : 'Sale'; $oldIsExpired = $old->isActive() && $old->isRental() && $old->agreement_end_date && $old->agreement_end_date->lt(\Carbon\Carbon::today()); @endphp
{{ $oldBadgeTxt }} @if($oldIsExpired) Expired @else Deactivated @endif {{ optional($old->property)->title ?? '—' }}
₹ {{ number_format((float)$old->agreed_price, 0) }}
{{ $old->deal_date ? $old->deal_date->format('d M Y') : '—' }}
@if($old->isRental() && $old->agreement_start_date && $old->agreement_end_date)
{{ $old->agreement_start_date->format('d M Y') }} → {{ $old->agreement_end_date->format('d M Y') }}
@if($old->monthly_rent)
₹ {{ number_format((float)$old->monthly_rent, 0) }}/mo
@endif @endif
Recorded by {{ optional($old->createdBy)->name ?? '—' }}
@if($oldIsExpired)
Agreement expired on {{ $old->agreement_end_date->format('d M Y') }}
@elseif($old->deactivated_at)
Deactivated {{ $old->deactivated_at->format('d M Y, H:i') }} @if($old->deactivatedBy) by {{ $old->deactivatedBy->name }} @endif @if($old->deactivation_note) — {{ $old->deactivation_note }} @endif
@endif
@if($old->document_path && $old->lead) Agreement @endif
@endforeach
@endif {{-- Activity Log --}}
Activity Log
@if($lead->activityLogs->isEmpty())
No activity recorded yet.
@else @endif
{{-- Add Note form --}}
@if($lead->isOpen()) {{-- Log Visit Modal --}} @endif {{-- Create Reminder Modal --}} @if($lead->isOpen()) {{-- Change Stage Modal --}} @endif @if($lead->isOpen()) {{-- Remove from Shortlist Modal --}} @endif {{-- Log Quote Modal --}} @if(! $agreement || ! $agreement->isActive() || $agreementIsExpired) {{-- Record Deal Modal --}} @endif @endsection @push('scripts') @endpush