mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Refactor for cache statics moving to container
This commit is contained in:
parent
f68d1d3053
commit
006e819f3a
@ -82,11 +82,15 @@ class RecurringExpenseToExpenseFactory
|
|||||||
} else {
|
} else {
|
||||||
$locale = $recurring_expense->company->locale();
|
$locale = $recurring_expense->company->locale();
|
||||||
|
|
||||||
$date_formats = Cache::get('date_formats');
|
//@deprecated
|
||||||
|
// $date_formats = Cache::get('date_formats');
|
||||||
|
|
||||||
$date_format = $date_formats->filter(function ($item) use ($recurring_expense) {
|
/** @var \Illuminate\Support\Collection<\App\Models\DateFormat> */
|
||||||
|
$date_formats = app('date_formats');
|
||||||
|
|
||||||
|
$date_format = $date_formats->first(function ($item) use ($recurring_expense) {
|
||||||
return $item->id == $recurring_expense->company->settings->date_format_id;
|
return $item->id == $recurring_expense->company->settings->date_format_id;
|
||||||
})->first()->format;
|
})->format;
|
||||||
}
|
}
|
||||||
|
|
||||||
Carbon::setLocale($locale);
|
Carbon::setLocale($locale);
|
||||||
|
@ -156,22 +156,16 @@ class TransactionTransformer implements BankRevenueInterface
|
|||||||
private function convertCurrency(string $code)
|
private function convertCurrency(string $code)
|
||||||
{
|
{
|
||||||
|
|
||||||
$currencies = Cache::get('currencies');
|
$currencies = app('currencies');
|
||||||
|
|
||||||
if (!$currencies) {
|
$currency = $currencies->first(function ($item) use ($code) {
|
||||||
$this->buildCache(true);
|
/** @var \App\Models\Currency $item */
|
||||||
}
|
|
||||||
|
|
||||||
$currency = $currencies->filter(function ($item) use ($code) {
|
|
||||||
return $item->code == $code;
|
return $item->code == $code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
|
||||||
return $currency->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
|
/** @var \App\Models\Currency $currency */
|
||||||
|
return $currency ? $currency->id : 1; //@phpstan-ignore-line
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function formatDate(string $input)
|
private function formatDate(string $input)
|
||||||
|
@ -171,20 +171,16 @@ class IncomeTransformer implements BankRevenueInterface
|
|||||||
|
|
||||||
private function convertCurrency(string $code)
|
private function convertCurrency(string $code)
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
|
||||||
if (! $currencies) {
|
$currencies = app('currencies');
|
||||||
$this->buildCache(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$currency = $currencies->filter(function ($item) use ($code) {
|
$currency = $currencies->first(function ($item) use ($code) {
|
||||||
|
/** @var \App\Models\Currency $item */
|
||||||
return $item->code == $code;
|
return $item->code == $code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
/** @var \App\Models\Currency $currency */
|
||||||
return $currency->id;
|
return $currency ? $currency->id : 1; //@phpstan-ignore-line
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,15 +90,20 @@ class SubscriptionPurchaseController extends Controller
|
|||||||
* Set locale for incoming request.
|
* Set locale for incoming request.
|
||||||
*
|
*
|
||||||
* @param string $locale
|
* @param string $locale
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function setLocale(string $locale): void
|
private function setLocale(string $locale): string
|
||||||
{
|
{
|
||||||
$record = Cache::get('languages')->filter(function ($item) use ($locale) {
|
|
||||||
return $item->locale == $locale;
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
})->first();
|
$languages = app('languages');
|
||||||
|
|
||||||
if ($record) {
|
$record = $languages->first(function ($item) use ($locale) {
|
||||||
App::setLocale($record->locale);
|
/** @var \App\Models\Language $item */
|
||||||
}
|
return $item->locale == $locale;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $record ? $record->locale : 'en';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,48 +185,44 @@ class StoreClientRequest extends Request
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLanguageId($language_code)
|
private function getLanguageId(string $language_code)
|
||||||
{
|
{
|
||||||
$languages = Cache::get('languages');
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
$language = $languages->filter(function ($item) use ($language_code) {
|
$language = $languages->first(function ($item) use ($language_code) {
|
||||||
return $item->locale == $language_code;
|
return $item->locale == $language_code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($language) {
|
return $language ? (string)$language->id : '';
|
||||||
return (string) $language->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCountryCode($country_code)
|
private function getCountryCode(string $country_code)
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
$country = $countries->filter(function ($item) use ($country_code) {
|
$country = $countries->first(function ($item) use ($country_code) {
|
||||||
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($country) {
|
return $country ? (string) $country->id : '';
|
||||||
return (string) $country->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCurrencyCode($code)
|
private function getCurrencyCode($code)
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
$currency = $currencies->filter(function ($item) use ($code) {
|
$currency = $currencies->first(function ($item) use ($code) {
|
||||||
return $item->code == $code;
|
return $item->code == $code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
return $currency ? (string)$currency->id : '';
|
||||||
return (string) $currency->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,32 +139,28 @@ class UpdateClientRequest extends Request
|
|||||||
|
|
||||||
private function getCountryCode($country_code)
|
private function getCountryCode($country_code)
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
$country = $countries->filter(function ($item) use ($country_code) {
|
$country = $countries->first(function ($item) use ($country_code) {
|
||||||
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($country) {
|
return $country ? (string) $country->id : '';
|
||||||
return (string) $country->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLanguageId($language_code)
|
private function getLanguageId($language_code)
|
||||||
{
|
{
|
||||||
$languages = Cache::get('languages');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
$language = $languages->filter(function ($item) use ($language_code) {
|
$language = $languages->first(function ($item) use ($language_code) {
|
||||||
return $item->locale == $language_code;
|
return $item->locale == $language_code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($language) {
|
return $language ? (string) $language->id : '';
|
||||||
return (string) $language->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,23 +155,27 @@ class StoreShopClientRequest extends Request
|
|||||||
|
|
||||||
private function getCountryCode($country_code)
|
private function getCountryCode($country_code)
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
$country = $countries->filter(function ($item) use ($country_code) {
|
$country = $countries->first(function ($item) use ($country_code) {
|
||||||
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
return (string) $country->id;
|
return $country ? (string) $country->id : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCurrencyCode($code)
|
private function getCurrencyCode($code)
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
$currency = $currencies->filter(function ($item) use ($code) {
|
$currency = $currencies->first(function ($item) use ($code) {
|
||||||
return $item->code == $code;
|
return $item->code == $code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
return (string) $currency->id;
|
return $currency ? (string) $currency->id : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,17 +119,18 @@ class BaseTransformer
|
|||||||
{
|
{
|
||||||
$code = array_key_exists($key, $data) ? $data[$key] : false;
|
$code = array_key_exists($key, $data) ? $data[$key] : false;
|
||||||
|
|
||||||
$currencies = Cache::get('currencies');
|
if(!$code)
|
||||||
|
return $this->company->settings->currency_id;
|
||||||
|
|
||||||
$currency = $currencies
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
->filter(function ($item) use ($code) {
|
$currencies = app('currencies');
|
||||||
return $item->code == $code;
|
|
||||||
})
|
$currency = $currencies->first(function ($item) use ($code) {
|
||||||
->first();
|
return $item->code == $code;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $currency ? (string) $currency->id : $this->company->settings->currency_id;
|
||||||
|
|
||||||
return $currency
|
|
||||||
? $currency->id
|
|
||||||
: $this->company->settings->currency_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFrequency($frequency = RecurringInvoice::FREQUENCY_MONTHLY): int
|
public function getFrequency($frequency = RecurringInvoice::FREQUENCY_MONTHLY): int
|
||||||
|
@ -256,7 +256,9 @@ class RegisterOrLogin extends Component
|
|||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
return view('billing-portal.v3.authentication.register-or-login', [
|
return view('billing-portal.v3.authentication.register-or-login', [
|
||||||
'countries' => $countries,
|
'countries' => $countries,
|
||||||
|
@ -281,17 +281,25 @@ class BillingPortalPurchase extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('currency_id', $this->request_data)) {
|
if (array_key_exists('currency_id', $this->request_data)) {
|
||||||
$currency = Cache::get('currencies')->filter(function ($item) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
|
$currency = $currencies->first(function ($item) {
|
||||||
return $item->id == $this->request_data['currency_id'];
|
return $item->id == $this->request_data['currency_id'];
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
if ($currency) {
|
||||||
$data['settings']->currency_id = $currency->id;
|
$data['settings']->currency_id = $currency->id;
|
||||||
}
|
}
|
||||||
} elseif ($this->subscription->group_settings && property_exists($this->subscription->group_settings->settings, 'currency_id')) {
|
} elseif ($this->subscription->group_settings && property_exists($this->subscription->group_settings->settings, 'currency_id')) {
|
||||||
$currency = Cache::get('currencies')->filter(function ($item) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
|
$currency = $currencies->first(function ($item) {
|
||||||
return $item->id == $this->subscription->group_settings->settings->currency_id;
|
return $item->id == $this->subscription->group_settings->settings->currency_id;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
if ($currency) {
|
||||||
$data['settings']->currency_id = $currency->id;
|
$data['settings']->currency_id = $currency->id;
|
||||||
@ -300,10 +308,12 @@ class BillingPortalPurchase extends Component
|
|||||||
|
|
||||||
if (array_key_exists('locale', $this->request_data)) {
|
if (array_key_exists('locale', $this->request_data)) {
|
||||||
$request = $this->request_data;
|
$request = $this->request_data;
|
||||||
|
|
||||||
$record = Cache::get('languages')->filter(function ($item) use ($request) {
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
$record = $languages->first(function ($item) use ($request) {
|
||||||
return $item->locale == $request['locale'];
|
return $item->locale == $request['locale'];
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($record) {
|
if ($record) {
|
||||||
$data['settings']['language_id'] = (string)$record->id;
|
$data['settings']['language_id'] = (string)$record->id;
|
||||||
|
@ -676,17 +676,25 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('currency_id', $this->request_data)) {
|
if (array_key_exists('currency_id', $this->request_data)) {
|
||||||
$currency = Cache::get('currencies')->filter(function ($item) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
|
$currency = $currencies->first(function ($item) {
|
||||||
return $item->id == $this->request_data['currency_id'];
|
return $item->id == $this->request_data['currency_id'];
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
if ($currency) {
|
||||||
$data['settings']->currency_id = $currency->id;
|
$data['settings']->currency_id = $currency->id;
|
||||||
}
|
}
|
||||||
} elseif ($this->subscription->group_settings && property_exists($this->subscription->group_settings->settings, 'currency_id')) {
|
} elseif ($this->subscription->group_settings && property_exists($this->subscription->group_settings->settings, 'currency_id')) {
|
||||||
$currency = Cache::get('currencies')->filter(function ($item) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
|
$currency = $currencies->first(function ($item) {
|
||||||
return $item->id == $this->subscription->group_settings->settings->currency_id;
|
return $item->id == $this->subscription->group_settings->settings->currency_id;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($currency) {
|
if ($currency) {
|
||||||
$data['settings']->currency_id = $currency->id;
|
$data['settings']->currency_id = $currency->id;
|
||||||
@ -696,9 +704,12 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
if (array_key_exists('locale', $this->request_data)) {
|
if (array_key_exists('locale', $this->request_data)) {
|
||||||
$request = $this->request_data;
|
$request = $this->request_data;
|
||||||
|
|
||||||
$record = Cache::get('languages')->filter(function ($item) use ($request) {
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
|
$record = $languages->first(function ($item) use ($request) {
|
||||||
return $item->locale == $request['locale'];
|
return $item->locale == $request['locale'];
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
if ($record) {
|
if ($record) {
|
||||||
$data['settings']['language_id'] = (string)$record->id;
|
$data['settings']['language_id'] = (string)$record->id;
|
||||||
|
@ -378,15 +378,11 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
|
|
||||||
public function language()
|
public function language()
|
||||||
{
|
{
|
||||||
$languages = app('languages');
|
|
||||||
// $languages = Cache::get('languages');
|
|
||||||
|
|
||||||
// if (! $languages) {
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
// $this->buildCache(true);
|
$languages = app('languages');
|
||||||
// }
|
|
||||||
|
|
||||||
return $languages->first(function ($item) {
|
return $languages->first(function ($item) {
|
||||||
/** @var \stdClass $item */
|
|
||||||
return $item->id == $this->getSetting('language_id');
|
return $item->id == $this->getSetting('language_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -412,17 +408,10 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
|
|
||||||
public function date_format()
|
public function date_format()
|
||||||
{
|
{
|
||||||
/** @var \Illuminate\Support\Collection $date_formats */
|
/** @var \Illuminate\Support\Collection<DateFormat> */
|
||||||
$date_formats = app('date_formats');
|
$date_formats = app('date_formats');
|
||||||
// $date_formats = Cache::get('date_formats');
|
|
||||||
|
|
||||||
// if (! $date_formats) {
|
|
||||||
// $this->buildCache(true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $date_formats->first(function ($item) {
|
return $date_formats->first(function ($item) {
|
||||||
|
|
||||||
/** @var \stdClass $item */
|
|
||||||
return $item->id == $this->getSetting('date_format_id');
|
return $item->id == $this->getSetting('date_format_id');
|
||||||
})->format;
|
})->format;
|
||||||
}
|
}
|
||||||
@ -430,17 +419,10 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
public function currency()
|
public function currency()
|
||||||
{
|
{
|
||||||
|
|
||||||
/** @var \Illuminate\Support\Collection $currencies */
|
/** @var \Illuminate\Support\Collection<Currency> */
|
||||||
$currencies = app('currencies');
|
$currencies = app('currencies');
|
||||||
// $currencies = Cache::get('currencies');
|
|
||||||
|
|
||||||
// if (! $currencies) {
|
|
||||||
// $this->buildCache(true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $currencies->first(function ($item) {
|
return $currencies->first(function ($item) {
|
||||||
|
|
||||||
/** @var \stdClass $item */
|
|
||||||
return $item->id == $this->getSetting('currency_id');
|
return $item->id == $this->getSetting('currency_id');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -751,16 +733,6 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
public function preferredLocale()
|
public function preferredLocale()
|
||||||
{
|
{
|
||||||
$this->language()->locale ?? 'en';
|
$this->language()->locale ?? 'en';
|
||||||
// $languages = app('languages');
|
|
||||||
// $languages = Cache::get('languages');
|
|
||||||
|
|
||||||
// if (! $languages) {
|
|
||||||
// $this->buildCache(true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return $languages->first(function ($item) {
|
|
||||||
// return $item->id == $this->getSetting('language_id');
|
|
||||||
// })->locale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function backup_path(): string
|
public function backup_path(): string
|
||||||
|
@ -271,15 +271,13 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
|||||||
|
|
||||||
public function preferredLocale()
|
public function preferredLocale()
|
||||||
{
|
{
|
||||||
$languages = Cache::get('languages');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
if (! $languages) {
|
return $languages->first(function ($item) {
|
||||||
$this->buildCache(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $languages->filter(function ($item) {
|
|
||||||
return $item->id == $this->client->getSetting('language_id');
|
return $item->id == $this->client->getSetting('language_id');
|
||||||
})->first()->locale;
|
})->locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routeNotificationForMail($notification)
|
public function routeNotificationForMail($notification)
|
||||||
|
@ -636,24 +636,13 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
$countries = app('countries');
|
$countries = app('countries');
|
||||||
|
|
||||||
// $countries = Cache::get('countries');
|
|
||||||
|
|
||||||
// if (! $companies) {
|
|
||||||
// $this->buildCache(true);
|
|
||||||
|
|
||||||
// $companies = Cache::get('countries');
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $countries->first(function ($item) {
|
return $countries->first(function ($item) {
|
||||||
|
|
||||||
/** @var \stdClass $item */
|
|
||||||
return $item->id == $this->getSetting('country_id');
|
return $item->id == $this->getSetting('country_id');
|
||||||
});
|
});
|
||||||
|
|
||||||
// return $this->belongsTo(Country::class);
|
|
||||||
// return Country::find($this->settings->country_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function group_settings()
|
public function group_settings()
|
||||||
@ -663,20 +652,14 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function timezone()
|
public function timezone()
|
||||||
{
|
{
|
||||||
// $timezones = Cache::get('timezones');
|
|
||||||
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\TimeZone> */
|
||||||
$timezones = app('timezones');
|
$timezones = app('timezones');
|
||||||
|
|
||||||
// if (! $timezones) {
|
|
||||||
// $this->buildCache(true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return $timezones->first(function ($item) {
|
return $timezones->first(function ($item) {
|
||||||
/** @var \stdClass $item */
|
|
||||||
return $item->id == $this->settings->timezone_id;
|
return $item->id == $this->settings->timezone_id;
|
||||||
});
|
});
|
||||||
|
|
||||||
// return Timezone::find($this->settings->timezone_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function designs()
|
public function designs()
|
||||||
@ -701,22 +684,15 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function language()
|
public function language()
|
||||||
{
|
{
|
||||||
$languages = Cache::get('languages');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
//build cache and reinit
|
$language = $languages->first(function ($item) {
|
||||||
if (! $languages) {
|
|
||||||
$this->buildCache(true);
|
|
||||||
$languages = Cache::get('languages');
|
|
||||||
}
|
|
||||||
|
|
||||||
//if the cache is still dead, get from DB
|
|
||||||
if (!$languages && property_exists($this->settings, 'language_id')) {
|
|
||||||
return Language::find($this->settings->language_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $languages->filter(function ($item) {
|
|
||||||
return $item->id == $this->settings->language_id;
|
return $item->id == $this->settings->language_id;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
|
return $language ?? $languages->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocale()
|
public function getLocale()
|
||||||
@ -757,11 +733,13 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function currency()
|
public function currency()
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
return $currencies->filter(function ($item) {
|
return $currencies->first(function ($item) {
|
||||||
return $item->id == $this->settings->currency_id;
|
return $item->id == $this->settings->currency_id;
|
||||||
})->first();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -974,15 +952,13 @@ class Company extends BaseModel
|
|||||||
|
|
||||||
public function date_format()
|
public function date_format()
|
||||||
{
|
{
|
||||||
$date_formats = Cache::get('date_formats');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\DateFormat> */
|
||||||
|
$date_formats = app('date_formats');
|
||||||
|
|
||||||
if (! $date_formats) {
|
return $date_formats->first(function ($item) {
|
||||||
$this->buildCache(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $date_formats->filter(function ($item) {
|
|
||||||
return $item->id == $this->getSetting('date_format_id');
|
return $item->id == $this->getSetting('date_format_id');
|
||||||
})->first()->format;
|
})->format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoiceCert()
|
public function getInvoiceCert()
|
||||||
|
@ -177,19 +177,17 @@ class Vendor extends BaseModel
|
|||||||
|
|
||||||
public function currency()
|
public function currency()
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
if (! $currencies) {
|
$currencies = app('currencies');
|
||||||
$this->buildCache(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $this->currency_id) {
|
if (! $this->currency_id) {
|
||||||
return $this->company->currency();
|
return $this->company->currency();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $currencies->filter(function ($item) {
|
return $currencies->first(function ($item) {
|
||||||
return $item->id == $this->currency_id;
|
return $item->id == $this->currency_id;
|
||||||
})->first();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function timezone()
|
public function timezone()
|
||||||
|
@ -183,11 +183,13 @@ class VendorContact extends Authenticatable implements HasLocalePreference
|
|||||||
|
|
||||||
public function preferredLocale()
|
public function preferredLocale()
|
||||||
{
|
{
|
||||||
$languages = Cache::get('languages');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
return $languages->filter(function ($item) {
|
return $languages->first(function ($item) {
|
||||||
return $item->id == $this->company->getSetting('language_id');
|
return $item->id == $this->company->getSetting('language_id');
|
||||||
})->first()->locale;
|
})->locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,11 +161,13 @@ class AuthorizeCustomer
|
|||||||
|
|
||||||
private function getCountryCode($country_code)
|
private function getCountryCode($country_code)
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
$country = $countries->filter(function ($item) use ($country_code) {
|
$country = $countries->first(function ($item) use ($country_code) {
|
||||||
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
return $item->iso_3166_2 == $country_code || $item->iso_3166_3 == $country_code;
|
||||||
})->first();
|
});
|
||||||
|
|
||||||
return (string) $country->id;
|
return (string) $country->id;
|
||||||
}
|
}
|
||||||
|
@ -33,56 +33,61 @@ class StaticServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
|
/** @return \Illuminate\Support\Collection<Currency> */
|
||||||
|
|
||||||
app()->singleton('currencies', function ($app) {
|
app()->singleton('currencies', function ($app) {
|
||||||
return Currency::query()->orderBy('name')->get();
|
return Currency::query()->orderBy('name')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Language> */
|
||||||
app()->singleton('languages', function ($app) {
|
app()->singleton('languages', function ($app) {
|
||||||
return Language::query()->orderBy('name')->get();
|
return Language::query()->orderBy('name')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Country> */
|
||||||
app()->singleton('countries', function ($app) {
|
app()->singleton('countries', function ($app) {
|
||||||
return Country::query()->orderBy('name')->get();
|
return Country::query()->orderBy('name')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<PaymentTerm> */
|
||||||
app()->singleton('payment_types', function ($app) {
|
app()->singleton('payment_types', function ($app) {
|
||||||
return PaymentTerm::query()->orderBy('num_days')->get();
|
return PaymentTerm::query()->orderBy('num_days')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Industry> */
|
||||||
app()->singleton('industries', function ($app) {
|
app()->singleton('industries', function ($app) {
|
||||||
return Industry::query()->orderBy('name')->get();
|
return Industry::query()->orderBy('name')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Bank> */
|
||||||
app()->singleton('banks', function ($app) {
|
app()->singleton('banks', function ($app) {
|
||||||
return Bank::query()->orderBy('name')->get();
|
return Bank::query()->orderBy('name')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<DateFormat> */
|
||||||
app()->singleton('date_formats', function ($app) {
|
app()->singleton('date_formats', function ($app) {
|
||||||
return DateFormat::query()->orderBy('id')->get();
|
return DateFormat::query()->orderBy('id')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Timezone> */
|
||||||
app()->singleton('timezones', function ($app) {
|
app()->singleton('timezones', function ($app) {
|
||||||
return Timezone::query()->orderBy('id')->get();
|
return Timezone::query()->orderBy('id')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Gateway> */
|
||||||
app()->singleton('gateways', function ($app) {
|
app()->singleton('gateways', function ($app) {
|
||||||
return Gateway::query()->orderBy('id')->get();
|
return Gateway::query()->orderBy('id')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Industry> */
|
||||||
app()->singleton('industries', function ($app) {
|
app()->singleton('industries', function ($app) {
|
||||||
return Industry::query()->orderBy('id')->get();
|
return Industry::query()->orderBy('id')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** @return \Illuminate\Support\Collection<Size> */
|
||||||
app()->singleton('sizes', function ($app) {
|
app()->singleton('sizes', function ($app) {
|
||||||
return Size::query()->orderBy('id')->get();
|
return Size::query()->orderBy('id')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
/** @deprecated */
|
|
||||||
app()->singleton('banks', function ($app) {
|
|
||||||
return Bank::query()->orderBy('id')->get();
|
|
||||||
});
|
|
||||||
|
|
||||||
app()->singleton('templates', function ($app) {
|
app()->singleton('templates', function ($app) {
|
||||||
return [
|
return [
|
||||||
|
@ -57,7 +57,9 @@ class ChartService
|
|||||||
/* Merge and filter by unique */
|
/* Merge and filter by unique */
|
||||||
$currencies = $currencies->merge($expense_currencies)->unique();
|
$currencies = $currencies->merge($expense_currencies)->unique();
|
||||||
|
|
||||||
$cache_currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$cache_currencies = app('currencies');
|
||||||
|
|
||||||
$filtered_currencies = $cache_currencies->whereIn('id', $currencies)->all();
|
$filtered_currencies = $cache_currencies->whereIn('id', $currencies)->all();
|
||||||
|
|
||||||
@ -162,7 +164,9 @@ class ChartService
|
|||||||
|
|
||||||
private function addCurrencyCodes($data_set): array
|
private function addCurrencyCodes($data_set): array
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
foreach ($data_set as $key => $value) {
|
foreach ($data_set as $key => $value) {
|
||||||
$data_set[$key]->currency_id = str_replace('"', '', $value->currency_id);
|
$data_set[$key]->currency_id = str_replace('"', '', $value->currency_id);
|
||||||
|
@ -53,7 +53,9 @@ class ChartServiceLegacy
|
|||||||
/* Merge and filter by unique */
|
/* Merge and filter by unique */
|
||||||
$currencies = $currencies->merge($expense_currencies)->unique();
|
$currencies = $currencies->merge($expense_currencies)->unique();
|
||||||
|
|
||||||
$cache_currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$cache_currencies = app('currencies');
|
||||||
|
|
||||||
$filtered_currencies = $cache_currencies->whereIn('id', $currencies)->all();
|
$filtered_currencies = $cache_currencies->whereIn('id', $currencies)->all();
|
||||||
|
|
||||||
@ -135,7 +137,9 @@ class ChartServiceLegacy
|
|||||||
|
|
||||||
private function addCurrencyCodes($data_set): array
|
private function addCurrencyCodes($data_set): array
|
||||||
{
|
{
|
||||||
$currencies = Cache::get('currencies');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
foreach ($data_set as $key => $value) {
|
foreach ($data_set as $key => $value) {
|
||||||
$data_set[$key]->currency_id = str_replace('"', '', $value->currency_id);
|
$data_set[$key]->currency_id = str_replace('"', '', $value->currency_id);
|
||||||
|
@ -457,15 +457,13 @@ class PdfConfiguration
|
|||||||
*/
|
*/
|
||||||
public function setDateFormat(): self
|
public function setDateFormat(): self
|
||||||
{
|
{
|
||||||
$date_formats = Cache::get('date_formats');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\DateFormat> */
|
||||||
|
$date_formats = app('date_formats');
|
||||||
|
|
||||||
if (! $date_formats) {
|
$this->date_format = $date_formats->first(function ($item) {
|
||||||
$this->buildCache(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->date_format = $date_formats->filter(function ($item) {
|
|
||||||
return $item->id == $this->settings->date_format_id;
|
return $item->id == $this->settings->date_format_id;
|
||||||
})->first()->format;
|
})->format;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -918,39 +918,30 @@ class HtmlEngine
|
|||||||
|
|
||||||
private function getCountryName(): string
|
private function getCountryName(): string
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
if (! $countries) {
|
$country = $countries->first(function ($item) {
|
||||||
$this->buildCache(true);
|
return $item->id == $this->settings->country_id;
|
||||||
|
});
|
||||||
|
|
||||||
$countries = Cache::get('countries');
|
return $country ? ctrans('texts.country_' . $country->name) : ctrans('texts.country_' . $countries->first()->name);
|
||||||
}
|
|
||||||
|
|
||||||
if ($countries) {
|
|
||||||
$country = $countries->filter(function ($item) {
|
|
||||||
return $item->id == $this->settings->country_id;
|
|
||||||
})->first();
|
|
||||||
} else {
|
|
||||||
$country = Country::find($this->settings->country_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($country) {
|
|
||||||
return ctrans('texts.country_' . $country->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ' ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function getCountryCode(): string
|
private function getCountryCode(): string
|
||||||
{
|
{
|
||||||
$country = Country::find($this->settings->country_id);
|
|
||||||
|
|
||||||
if ($country) {
|
|
||||||
return $country->iso_3166_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ' ';
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
|
$country = $countries->first(function ($item) {
|
||||||
|
return $item->id == $this->settings->country_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $country ? $country->iso_3166_2 : ' ';
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Due to the way we are compiling the blade template we
|
* Due to the way we are compiling the blade template we
|
||||||
|
@ -69,62 +69,81 @@ class Statics
|
|||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
foreach (config('ninja.cached_tables') as $name => $class) {
|
// foreach (config('ninja.cached_tables') as $name => $class) {
|
||||||
if (! Cache::has($name)) {
|
// if (! Cache::has($name)) {
|
||||||
// check that the table exists in case the migration is pending
|
// // check that the table exists in case the migration is pending
|
||||||
if (! Schema::hasTable((new $class())->getTable())) {
|
// if (! Schema::hasTable((new $class())->getTable())) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
if ($name == 'payment_terms') {
|
// if ($name == 'payment_terms') {
|
||||||
$orderBy = 'num_days';
|
// $orderBy = 'num_days';
|
||||||
} elseif ($name == 'fonts') {
|
// } elseif ($name == 'fonts') {
|
||||||
$orderBy = 'sort_order';
|
// $orderBy = 'sort_order';
|
||||||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
// } elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
||||||
$orderBy = 'name';
|
// $orderBy = 'name';
|
||||||
} else {
|
// } else {
|
||||||
$orderBy = 'id';
|
// $orderBy = 'id';
|
||||||
}
|
// }
|
||||||
$tableData = $class::orderBy($orderBy)->get();
|
// $tableData = $class::orderBy($orderBy)->get();
|
||||||
if ($tableData->count()) {
|
// if ($tableData->count()) {
|
||||||
Cache::forever($name, $tableData);
|
// Cache::forever($name, $tableData);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
$data[$name] = Cache::get($name);
|
// $data[$name] = app($name);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ($locale) {
|
if ($locale) {
|
||||||
$data['industries'] = Cache::get('industries')->each(function ($industry) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Industry> */
|
||||||
|
$industries = app('industries');
|
||||||
|
|
||||||
|
$data['industries'] = $industries->each(function ($industry) {
|
||||||
$industry->name = ctrans('texts.industry_'.$industry->name);
|
$industry->name = ctrans('texts.industry_'.$industry->name);
|
||||||
})->sortBy(function ($industry) {
|
})->sortBy(function ($industry) {
|
||||||
return $industry->name;
|
return $industry->name;
|
||||||
})->values();
|
})->values();
|
||||||
|
|
||||||
$data['countries'] = Cache::get('countries')->each(function ($country) {
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
|
$data['countries'] = $countries->each(function ($country) {
|
||||||
$country->name = ctrans('texts.country_'.$country->name);
|
$country->name = ctrans('texts.country_'.$country->name);
|
||||||
})->sortBy(function ($country) {
|
})->sortBy(function ($country) {
|
||||||
return $country->name;
|
return $country->name;
|
||||||
})->values();
|
})->values();
|
||||||
|
|
||||||
$data['payment_types'] = Cache::get('payment_types')->each(function ($pType) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\PaymentType> */
|
||||||
|
$payment_types = app('payment_types');
|
||||||
|
|
||||||
|
$data['payment_types'] = $payment_types->each(function ($pType) {
|
||||||
$pType->name = ctrans('texts.payment_type_'.$pType->name);
|
$pType->name = ctrans('texts.payment_type_'.$pType->name);
|
||||||
})->sortBy(function ($pType) {
|
})->sortBy(function ($pType) {
|
||||||
return $pType->name;
|
return $pType->name;
|
||||||
})->values();
|
})->values();
|
||||||
|
|
||||||
$data['languages'] = Cache::get('languages')->each(function ($lang) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$payment_types = app('languages');
|
||||||
|
|
||||||
|
$data['languages'] = $payment_types->each(function ($lang) {
|
||||||
$lang->name = ctrans('texts.lang_'.$lang->name);
|
$lang->name = ctrans('texts.lang_'.$lang->name);
|
||||||
})->sortBy(function ($lang) {
|
})->sortBy(function ($lang) {
|
||||||
return $lang->name;
|
return $lang->name;
|
||||||
})->values();
|
})->values();
|
||||||
|
|
||||||
$data['currencies'] = Cache::get('currencies')->each(function ($currency) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
|
$data['currencies'] = $currencies->each(function ($currency) {
|
||||||
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));
|
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));
|
||||||
})->sortBy(function ($currency) {
|
})->sortBy(function ($currency) {
|
||||||
return $currency->name;
|
return $currency->name;
|
||||||
})->values();
|
})->values();
|
||||||
|
|
||||||
$data['templates'] = Cache::get('templates');
|
$data['templates'] = app('templates');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['bulk_updates'] = [
|
$data['bulk_updates'] = [
|
||||||
|
@ -19,7 +19,11 @@ class TranslationHelper
|
|||||||
{
|
{
|
||||||
public static function getIndustries()
|
public static function getIndustries()
|
||||||
{
|
{
|
||||||
return Cache::get('industries')->each(function ($industry) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$industries = app('industries');
|
||||||
|
|
||||||
|
return $industries->each(function ($industry) {
|
||||||
$industry->name = ctrans('texts.industry_'.$industry->name);
|
$industry->name = ctrans('texts.industry_'.$industry->name);
|
||||||
})->sortBy(function ($industry) {
|
})->sortBy(function ($industry) {
|
||||||
return $industry->name;
|
return $industry->name;
|
||||||
@ -28,7 +32,11 @@ class TranslationHelper
|
|||||||
|
|
||||||
public static function getCountries()
|
public static function getCountries()
|
||||||
{
|
{
|
||||||
return Cache::get('countries')->each(function ($country) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
|
return $countries->each(function ($country) {
|
||||||
$country->name = ctrans('texts.country_'.$country->name);
|
$country->name = ctrans('texts.country_'.$country->name);
|
||||||
})->sortBy(function ($country) {
|
})->sortBy(function ($country) {
|
||||||
return $country->iso_3166_2;
|
return $country->iso_3166_2;
|
||||||
@ -37,7 +45,11 @@ class TranslationHelper
|
|||||||
|
|
||||||
public static function getPaymentTypes()
|
public static function getPaymentTypes()
|
||||||
{
|
{
|
||||||
return Cache::get('payment_types')->each(function ($pType) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\PaymentType> */
|
||||||
|
$payment_types = app('payment_types');
|
||||||
|
|
||||||
|
return $payment_types->each(function ($pType) {
|
||||||
$pType->name = ctrans('texts.payment_type_'.$pType->name);
|
$pType->name = ctrans('texts.payment_type_'.$pType->name);
|
||||||
})->sortBy(function ($pType) {
|
})->sortBy(function ($pType) {
|
||||||
return $pType->name;
|
return $pType->name;
|
||||||
@ -46,7 +58,11 @@ class TranslationHelper
|
|||||||
|
|
||||||
public static function getLanguages()
|
public static function getLanguages()
|
||||||
{
|
{
|
||||||
return Cache::get('languages')->each(function ($lang) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Language> */
|
||||||
|
$languages = app('languages');
|
||||||
|
|
||||||
|
return $languages->each(function ($lang) {
|
||||||
$lang->name = ctrans('texts.lang_'.$lang->name);
|
$lang->name = ctrans('texts.lang_'.$lang->name);
|
||||||
})->sortBy(function ($lang) {
|
})->sortBy(function ($lang) {
|
||||||
return $lang->name;
|
return $lang->name;
|
||||||
@ -55,7 +71,11 @@ class TranslationHelper
|
|||||||
|
|
||||||
public static function getCurrencies()
|
public static function getCurrencies()
|
||||||
{
|
{
|
||||||
return Cache::get('currencies')->each(function ($currency) {
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Currency> */
|
||||||
|
$currencies = app('currencies');
|
||||||
|
|
||||||
|
return $currencies->each(function ($currency) {
|
||||||
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));
|
$currency->name = ctrans('texts.currency_'.Str::slug($currency->name, '_'));
|
||||||
})->sortBy(function ($currency) {
|
})->sortBy(function ($currency) {
|
||||||
return $currency->name;
|
return $currency->name;
|
||||||
|
@ -567,27 +567,15 @@ class VendorHtmlEngine
|
|||||||
|
|
||||||
private function getCountryName(): string
|
private function getCountryName(): string
|
||||||
{
|
{
|
||||||
$countries = Cache::get('countries');
|
|
||||||
|
/** @var \Illuminate\Support\Collection<\App\Models\Country> */
|
||||||
|
$countries = app('countries');
|
||||||
|
|
||||||
if (! $countries) {
|
$country = $countries->first(function ($item) {
|
||||||
$this->buildCache(true);
|
return $item->id == $this->settings->country_id;
|
||||||
|
});
|
||||||
$countries = Cache::get('countries');
|
|
||||||
}
|
return $country ? ctrans('texts.country_' . $country->name) : ' ';
|
||||||
|
|
||||||
if ($countries) {
|
|
||||||
$country = $countries->filter(function ($item) {
|
|
||||||
return $item->id == $this->settings->country_id;
|
|
||||||
})->first();
|
|
||||||
} else {
|
|
||||||
$country = Country::find($this->settings->country_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($country) {
|
|
||||||
return ctrans('texts.country_' . $country->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ' ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user