From c532a43e706a814d8a54b153b71a2b837af96e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 2 Apr 2024 13:12:30 +0200 Subject: [PATCH] Fixes for auto submitting the form --- app/Livewire/RequiredClientInfo.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Livewire/RequiredClientInfo.php b/app/Livewire/RequiredClientInfo.php index 240d803c8366..b174a87cf8fd 100644 --- a/app/Livewire/RequiredClientInfo.php +++ b/app/Livewire/RequiredClientInfo.php @@ -12,7 +12,6 @@ namespace App\Livewire; -use App\Models\Client; use App\Models\Invoice; use Livewire\Component; use App\Libraries\MultiDB; @@ -187,6 +186,7 @@ class RequiredClientInfo extends Component public $company_gateway_id; public bool $form_only = false; + public $db; public function mount() @@ -223,7 +223,7 @@ class RequiredClientInfo extends Component $this->show_form = true; $hash = Cache::get(request()->input('hash')); - + /** @var \App\Models\Invoice $invoice */ $invoice = Invoice::find($this->decodePrimaryKey($hash['invoice_id'])); @@ -250,7 +250,7 @@ class RequiredClientInfo extends Component MultiDB::setDb($this->db); return ClientContact::withTrashed()->find($this->contact_id); - + } #[Computed] @@ -269,7 +269,7 @@ class RequiredClientInfo extends Component public function handleSubmit(array $data): bool { - + MultiDB::setDb($this->db); $contact = ClientContact::withTrashed()->find($this->contact_id); @@ -377,7 +377,6 @@ $_contact->push(); public function checkFields() { - MultiDB::setDb($this->db); $_contact = ClientContact::withTrashed()->find($this->contact_id); @@ -385,7 +384,10 @@ $_contact->push(); $_field = $this->mappings[$field['name']]; if (Str::startsWith($field['name'], 'client_')) { - if (empty($_contact->client->{$_field}) || is_null($_contact->client->{$_field}) || in_array($_field, $this->client_address_array)) { + if (empty($_contact->client->{$_field}) + || is_null($_contact->client->{$_field}) + // || in_array($_field, $this->client_address_array) + ) { $this->show_form = true; } else { $this->fields[$index]['filled'] = true;