From 34cf93b78ef0f08d00ac4413428e1ffcb1fc16e3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Nov 2019 21:32:01 +1100 Subject: [PATCH] Portal Domain Validation (#3098) * fix for blank client settings * Force all custom fields to strings * Fixes for bulk actions * Fix for client transformer * Validation for portal domain -> url * Portal Domain Validation --- app/Http/Requests/Company/StoreCompanyRequest.php | 2 +- app/Http/Requests/Company/UpdateCompanyRequest.php | 2 ++ app/Transformers/ClientTransformer.php | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/Company/StoreCompanyRequest.php b/app/Http/Requests/Company/StoreCompanyRequest.php index 551616a4a18d..37a7abf94069 100644 --- a/app/Http/Requests/Company/StoreCompanyRequest.php +++ b/app/Http/Requests/Company/StoreCompanyRequest.php @@ -37,7 +37,7 @@ class StoreCompanyRequest extends Request //$rules['name'] = 'required'; $rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb $rules['settings'] = new ValidSettingsRule(); - + $rules['portal_domain'] = 'url'; return $rules; } diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index 730898da649a..78c085f9264c 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -43,6 +43,8 @@ class UpdateCompanyRequest extends Request $rules['size_id'] = 'integer|nullable'; $rules['country_id'] = 'integer|nullable'; $rules['work_email'] = 'email|nullable'; + $rules['portal_domain'] = 'url'; + return $rules; diff --git a/app/Transformers/ClientTransformer.php b/app/Transformers/ClientTransformer.php index 5a19ab4a98d8..ba1587f2af3c 100644 --- a/app/Transformers/ClientTransformer.php +++ b/app/Transformers/ClientTransformer.php @@ -94,8 +94,8 @@ class ClientTransformer extends EntityTransformer 'city' => $client->city ?: '', 'state' => $client->state ?: '', 'postal_code' => $client->postal_code ?: '', - 'country_id' => $client->country_id ?: '', - 'industry_id' => $client->industry_id ?: '', + 'country_id' => (string)$client->country_id ?: '', + 'industry_id' => (string)$client->industry_id ?: '', 'custom_value1' => $client->custom_value1 ?: '', 'custom_value2' => $client->custom_value2 ?: '', 'custom_value3' => $client->custom_value3 ?: '', @@ -105,7 +105,7 @@ class ClientTransformer extends EntityTransformer 'shipping_city' => $client->shipping_city ?: '', 'shipping_state' => $client->shipping_state ?: '', 'shipping_postal_code' => $client->shipping_postal_code ?: '', - 'shipping_country_id' => $client->shipping_country_id ?: '', + 'shipping_country_id' => (string)$client->shipping_country_id ?: '', 'settings' => $client->settings ?: new \stdClass, 'is_deleted' => (bool) $client->is_deleted, 'vat_number' => $client->vat_number ?: '',