mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Handle service failure
This commit is contained in:
parent
edc944a122
commit
d02b15d642
@ -64,29 +64,30 @@ class AccountRepository
|
||||
|
||||
// Set default language/currency based on IP
|
||||
if (\Cache::get('currencies')) {
|
||||
$data = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $account->ip));
|
||||
$currencyCode = strtolower($data['geoplugin_currencyCode']);
|
||||
$countryCode = strtolower($data['geoplugin_countryCode']);
|
||||
if ($data = unserialize(@file_get_contents('http://www.geoplugin.net/php.gp?ip=' . $account->ip))) {
|
||||
$currencyCode = strtolower($data['geoplugin_currencyCode']);
|
||||
$countryCode = strtolower($data['geoplugin_countryCode']);
|
||||
|
||||
$currency = \Cache::get('currencies')->filter(function ($item) use ($currencyCode) {
|
||||
return strtolower($item->code) == $currencyCode;
|
||||
})->first();
|
||||
if ($currency) {
|
||||
$account->currency_id = $currency->id;
|
||||
}
|
||||
$currency = \Cache::get('currencies')->filter(function ($item) use ($currencyCode) {
|
||||
return strtolower($item->code) == $currencyCode;
|
||||
})->first();
|
||||
if ($currency) {
|
||||
$account->currency_id = $currency->id;
|
||||
}
|
||||
|
||||
$country = \Cache::get('countries')->filter(function ($item) use ($countryCode) {
|
||||
return strtolower($item->iso_3166_2) == $countryCode || strtolower($item->iso_3166_3) == $countryCode;
|
||||
})->first();
|
||||
if ($country) {
|
||||
$account->country_id = $country->id;
|
||||
}
|
||||
$country = \Cache::get('countries')->filter(function ($item) use ($countryCode) {
|
||||
return strtolower($item->iso_3166_2) == $countryCode || strtolower($item->iso_3166_3) == $countryCode;
|
||||
})->first();
|
||||
if ($country) {
|
||||
$account->country_id = $country->id;
|
||||
}
|
||||
|
||||
$language = \Cache::get('languages')->filter(function ($item) use ($countryCode) {
|
||||
return strtolower($item->locale) == $countryCode;
|
||||
})->first();
|
||||
if ($language) {
|
||||
$account->language_id = $language->id;
|
||||
$language = \Cache::get('languages')->filter(function ($item) use ($countryCode) {
|
||||
return strtolower($item->locale) == $countryCode;
|
||||
})->first();
|
||||
if ($language) {
|
||||
$account->language_id = $language->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user