From ce400365a5f497f971f7ef2fb68d5c3ff5179156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 1 Apr 2024 19:04:40 +0200 Subject: [PATCH] Add additional fields to ClientRegisterService mappings --- .../Authentication/ClientRegisterService.php | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/app/Livewire/BillingPortal/Authentication/ClientRegisterService.php b/app/Livewire/BillingPortal/Authentication/ClientRegisterService.php index 76c1162c4d39..35cea03d6941 100644 --- a/app/Livewire/BillingPortal/Authentication/ClientRegisterService.php +++ b/app/Livewire/BillingPortal/Authentication/ClientRegisterService.php @@ -27,6 +27,7 @@ class ClientRegisterService public function __construct( public Company $company, + public array $additional = [], ) { } @@ -54,6 +55,12 @@ class ClientRegisterService $rules['terms'] = ['required']; } + foreach ($this->additional as $field) { + if ($field['visible'] ?? true) { + $rules[$field['key']] = $field['required'] ? ['bail', 'required'] : ['sometimes']; + } + } + return $rules; } @@ -97,4 +104,29 @@ class ClientRegisterService return $client_contact; } -} \ No newline at end of file + + public static function mappings(): array + { + return [ + 'contact_first_name' => 'first_name', + 'contact_last_name' => 'last_name', + 'contact_email' => 'email', + 'client_phone' => 'phone', + 'client_city' => 'city', + 'client_address_line_1' => 'address1', + 'client_address_line_2' => 'address2', + 'client_state' => 'state', + 'client_country_id' => 'country_id', + 'client_postal_code' => 'postal_code', + 'client_shipping_postal_code' => 'shipping_postal_code', + 'client_shipping_address_line_1' => 'shipping_address1', + 'client_shipping_city' => 'shipping_city', + 'client_shipping_state' => 'shipping_state', + 'client_shipping_country_id' => 'shipping_country_id', + 'client_custom_value1' => 'custom_value1', + 'client_custom_value2' => 'custom_value2', + 'client_custom_value3' => 'custom_value3', + 'client_custom_value4' => 'custom_value4', + ]; + } +}