1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Make state field optional

This commit is contained in:
Hillel Coren 2018-03-13 16:04:02 +02:00
parent a4215a6fbe
commit ca3ff553e5
5 changed files with 13 additions and 5 deletions

View File

@ -988,7 +988,7 @@ class ClientPortalController extends BaseController
'email' => 'required',
'address1' => 'required',
'city' => 'required',
'state' => 'required',
'state' => $account->requiresAddressState() ? 'required' : '',
'postal_code' => 'required',
'country_id' => 'required',
];

View File

@ -1791,6 +1791,11 @@ class Account extends Eloquent
return url('/');
}
}
public function requiresAddressState() {
return true;
//return ! $this->country_id || $this->country_id == DEFAULT_COUNTRY;
}
}
Account::creating(function ($account)

View File

@ -242,10 +242,13 @@ class BasePaymentDriver
$rules = array_merge($rules, [
'address1' => 'required',
'city' => 'required',
'state' => 'required',
'postal_code' => 'required',
'country_id' => 'required',
]);
if ($this->account()->requiresAddressState()) {
$rules['state'] = 'required';
}
}
}

View File

@ -25,7 +25,7 @@
'vat_number' => 'required',
'address1' => 'required',
'city' => 'required',
'state' => 'required',
'state' => $account->requiresAddressState() ? 'required' : '',
'postal_code' => 'required',
'country_id' => 'required',
)) !!}

View File

@ -133,7 +133,7 @@
'cvv' => 'required',
'address1' => 'required',
'city' => 'required',
'state' => 'required',
'state' => $account->requiresAddressState() ? 'required' : '',
'postal_code' => 'required',
'country_id' => 'required',
'phone' => 'required',
@ -146,7 +146,7 @@
'account_holder_type' => 'required',
'shipping_address1' => 'required',
'shipping_city' => 'required',
'shipping_state' => 'required',
'shipping_state' => $account->requiresAddressState() ? 'required' : '',
'shipping_postal_code' => 'required',
'shipping_country_id' => 'required',
)) !!}