@php $editing = isset($invoice) && $invoice; $action = $editing ? route('invoices.update', $invoice) : route('invoices.store'); $method = $editing ? 'PUT' : 'POST'; if ($editing && $invoice->items->isNotEmpty()) { $rows = $invoice->items; } else { $rows = collect([(object) ['description' => '', 'quantity' => 1, 'unit_rate' => '', 'total' => 0]]); } @endphp