@extends('admin.layouts.app') @section('title','Create Quotation') @section('content') @php $isEdit = isset($quotation); $selectedLeadId = old('lead_id', $lead?->id); $formItems = collect(); if (old('service_name')) { foreach (old('service_name') as $index => $name) { $formItems->push(['service_name'=>$name,'description'=>old("description.$index"),'quantity'=>old("quantity.$index",1),'unit_price'=>old("unit_price.$index",0)]); } } elseif ($isEdit) { $formItems = $quotation->items->map(fn($item)=>['service_name'=>$item->service_name,'description'=>$item->description,'quantity'=>$item->quantity,'unit_price'=>$item->unit_price]); } else { $formItems->push(['service_name'=>$lead?->enquiry_type ?? '','description'=>'','quantity'=>1,'unit_price'=>0]); } @endphp
{{ $isEdit ? $quotation->quotation_number : 'Select a converted lead and prepare its quotation.' }}