← All changes
|
app/Http/Requests/FrontendRequests/CustomerRequests/CustomerProfileRequest.php
+28
-3
1.3.26
→
1.6.5
View file →
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\Http\Requests\FrontendRequests\CustomerRequests; |
| 4 | 4 | |
| 5 | +use FluentCart\App\Services\Renderer\CheckoutFieldsSchema; | |
| 5 | 6 | use FluentCart\Framework\Foundation\RequestGuard; |
| 6 | 7 | use FluentCart\Framework\Support\Arr; |
| 7 | 8 | |
| 8 | 9 | class CustomerProfileRequest extends RequestGuard |
| @@ -24,10 +25,9 @@ | ||
| 24 | 25 | * @return array |
| 25 | 26 | */ |
| 26 | 27 | public function rules() |
| 27 | 28 | { |
| 28 | - | |
| 29 | - return [ | |
| 29 | + $rules = [ | |
| 30 | 30 | 'label' => 'nullable|sanitizeText|maxLength:15', |
| 31 | 31 | 'name' => 'required|sanitizeText|maxLength:255', |
| 32 | 32 | 'address_1' => 'nullable|sanitizeTextArea', |
| 33 | 33 | 'address_2' => 'nullable|sanitizeTextArea', |
| @@ -41,9 +41,27 @@ | ||
| 41 | 41 | 'current_password' => 'sanitizeText|nullable', |
| 42 | 42 | 'new_password' => 'sanitizeText|nullable', |
| 43 | 43 | 'confirm_new_password' => 'sanitizeText|nullable', |
| 44 | 44 | 'company_name' => 'nullable|sanitizeText|maxLength:255', |
| 45 | + 'vat_number' => 'nullable|sanitizeText|maxLength:255', | |
| 46 | + 'legal_registration_id' => 'nullable|sanitizeText|maxLength:255', | |
| 45 | 47 | ]; |
| 48 | + | |
| 49 | + if (Arr::get($this->all(), 'type') === 'billing') { | |
| 50 | + if (CheckoutFieldsSchema::isCompanyNameEnabled() && CheckoutFieldsSchema::isCompanyNameRequired()) { | |
| 51 | + $rules['company_name'] = 'required|sanitizeText|maxLength:255'; | |
| 52 | + } | |
| 53 | + | |
| 54 | + if (CheckoutFieldsSchema::isVatNumberEnabled() && CheckoutFieldsSchema::isVatNumberRequired()) { | |
| 55 | + $rules['vat_number'] = 'required|sanitizeText|maxLength:255'; | |
| 56 | + } | |
| 57 | + | |
| 58 | + if (CheckoutFieldsSchema::isLegalRegistrationIdEnabled() && CheckoutFieldsSchema::isLegalRegistrationIdRequired()) { | |
| 59 | + $rules['legal_registration_id'] = 'required|sanitizeText|maxLength:255'; | |
| 60 | + } | |
| 61 | + } | |
| 62 | + | |
| 63 | + return $rules; | |
| 46 | 64 | } |
| 47 | 65 | |
| 48 | 66 | /** |
| 49 | 67 | * @return array |
| @@ -55,9 +73,12 @@ | ||
| 55 | 73 | 'address_1.required' => esc_html__('Street Address is required.', 'fluent-cart'), |
| 56 | 74 | 'city.required' => esc_html__('City field is required.', 'fluent-cart'), |
| 57 | 75 | 'postcode.required' => esc_html__('Postcode field is required.', 'fluent-cart'), |
| 58 | 76 | 'country.required' => esc_html__('Country field is required.', 'fluent-cart'), |
| 59 | - 'email.required' => esc_html__('Email field is required.', 'fluent-cart') | |
| 77 | + 'email.required' => esc_html__('Email field is required.', 'fluent-cart'), | |
| 78 | + 'company_name.required' => esc_html__('Company Name field is required.', 'fluent-cart'), | |
| 79 | + 'vat_number.required' => esc_html__('VAT/GST/Tax Number field is required.', 'fluent-cart'), | |
| 80 | + 'legal_registration_id.required' => esc_html__('Legal Registration ID field is required.', 'fluent-cart') | |
| 60 | 81 | ]; |
| 61 | 82 | } |
| 62 | 83 | |
| 63 | 84 | /** |
| @@ -91,8 +112,10 @@ | ||
| 91 | 112 | 'status' => 'sanitize_text_field', |
| 92 | 113 | 'userId' => 'sanitize_text_field', |
| 93 | 114 | 'customerId' => 'sanitize_text_field', |
| 94 | 115 | 'company_name' => 'sanitize_text_field', |
| 116 | + 'vat_number' => 'sanitize_text_field', | |
| 117 | + 'legal_registration_id' => 'sanitize_text_field', | |
| 95 | 118 | |
| 96 | 119 | 'address.type' => 'sanitize_text_field', |
| 97 | 120 | 'address.name' => 'sanitize_text_field', |
| 98 | 121 | 'address.address_1' => 'sanitize_text_field', |
| @@ -111,7 +134,9 @@ | ||
| 111 | 134 | }, |
| 112 | 135 | 'address.is_primary' => 'sanitize_text_field', |
| 113 | 136 | 'address.status' => 'sanitize_text_field', |
| 114 | 137 | 'address.company_name' => 'sanitize_text_field', |
| 138 | + 'address.vat_number' => 'sanitize_text_field', | |
| 139 | + 'address.legal_registration_id' => 'sanitize_text_field', | |
| 115 | 140 | ]; |
| 116 | 141 | } |
| 117 | 142 | } |