*/ public array $fields = []; public bool $is_loading = true; public array $errors = []; public function mount(): void { MultiDB::setDB( $this->getContext()['db'], ); $this->fields = $this->getContext()['fields']; $this->company_gateway = CompanyGateway::withTrashed() ->with('company') ->find($this->getContext()['company_gateway_id']); $contact = auth()->user(); $this->client_name = $contact->client->name; $this->contact_first_name = $contact->first_name; $this->contact_last_name = $contact->last_name; $this->contact_email = $contact->email; $this->client_phone = $contact->client->phone; $this->client_address_line_1 = $contact->client->address1; $this->client_city = $contact->client->city; $this->client_state = $contact->client->state; $this->client_country_id = $contact->client->country_id; $this->client_postal_code = $contact->client->postal_code; $this->client_shipping_address_line_1 = $contact->client->shipping_address1; $this->client_shipping_city = $contact->client->shipping_city; $this->client_shipping_state = $contact->client->shipping_state; $this->client_shipping_postal_code = $contact->client->shipping_postal_code; $this->client_shipping_country_id = $contact->client->shipping_country_id; $this->client_custom_value1 = $contact->client->custom_value1; $this->client_custom_value2 = $contact->client->custom_value2; $this->client_custom_value3 = $contact->client->custom_value3; $this->client_custom_value4 = $contact->client->custom_value4; $rff = new RFFService( fields: $this->getContext()['fields'], database: $this->getContext()['db'], company_gateway_id: (string)$this->company_gateway->id, ); /** @var \App\Models\ClientContact $contact */ $rff->check($contact); if ($rff->unfilled_fields === 0) { $this->dispatch('required-fields'); } if ($rff->unfilled_fields > 0) { $this->is_loading = false; } } public function handleSubmit(array $data) { $this->errors = []; $this->is_loading = true; $rff = new RFFService( fields: $this->fields, database: $this->getContext()['db'], company_gateway_id: (string) $this->company_gateway->id, ); $contact = auth()->user(); /** @var \App\Models\ClientContact $contact */ $errors = $rff->handleSubmit($data, $contact, return_errors: true, callback: function () { $this->dispatch('required-fields'); }); if (is_array($errors) && count($errors)) { $this->errors = $errors; $this->is_loading = false; } } public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View { return render('flow2.required-fields', [ 'contact' => $this->getContext()['contact'], ]); } }