with('client')->get()->sortBy('client.abbreviation'); } public function loadContacts(): void { if (!$this->invoice_id) { $this->contacts = []; return; } $invoice = Invoice::find($this->invoice_id); $this->contacts = $invoice?->client?->contacts ?? collect(); } public function updatedInvoiceId(): void { $this->loadContacts(); $this->contact_id = null; } #[On('edit-payment')] public function loadPayment(int $paymentId): void { $this->payment = Payment::findOrFail($paymentId); $this->invoice_id = $this->payment->invoice_id; $this->loadContacts(); $this->contact_id = $this->payment->contact_id; $this->payment_date = $this->payment->payment_date->format('Y-m-d'); $this->status = $this->payment->status; $this->payment_method = $this->payment->payment_method; $this->reference = $this->payment->reference; $this->amount = $this->payment->amount; $this->notes = $this->payment->notes; Flux::modal('edit-payment')->show(); } public function save(): void { $this->validate(); $this->payment->update([ 'invoice_id' => $this->invoice_id, 'contact_id' => $this->contact_id, 'payment_date' => $this->payment_date, 'status' => $this->status, 'payment_method' => $this->payment_method, 'reference' => $this->reference, 'amount' => $this->amount, 'notes' => $this->notes, ]); Flux::modal('edit-payment')->close(); $this->dispatch('payment-updated'); } }; ?>