@php $isEdit = isset($quote); $quoteStatuses = \App\Models\Quote::statuses(); $defaultQuoteNumber = 'QT-'.now()->format('Ymd').'-'.str_pad((string) random_int(1, 999), 3, '0', STR_PAD_LEFT); $selectedClient = old('client_id', $isEdit ? $quote->client_id : ($selectedClientId ?? null)); $selectedProject = old('project_id', $isEdit ? $quote->project_id : ($selectedProjectId ?? null)); $existingItems = old('items'); if ($existingItems === null) { $existingItems = $isEdit ? $quote->items->map(fn ($item) => [ 'title' => $item->title, 'description' => $item->description, 'quantity' => (float) $item->quantity, 'unit' => $item->unit, 'unit_price' => (float) $item->unit_price, ])->values()->all() : []; } if (count($existingItems) === 0) { $existingItems[] = ['title' => '', 'description' => '', 'quantity' => 1, 'unit' => '', 'unit_price' => 0]; } @endphp
@push('scripts') @endpush