app->environment('production')); // * HTTPS FIX URL::forceScheme('https'); // * HA PROXY FIX App::singleton('clientIp', function () { if (config('app.env') === 'local') { return request()->getClientIp(); } else { return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp(); } }); // * LOCAL FORCE eg: for Carbon setlocale(LC_ALL, \sprintf( '%s_%s.UTF-8', config('app.locale'), \strtoupper(config('app.locale')) )); Carbon::setLocale(config('app.locale')); // * SETTINGS App::singleton('settings', fn () => GeneralSetting::getCached()); // * Menu App::singleton('menuNodeList', fn () => App::get('settings') ->where('type', SettingsType::mainMenu)->firstOrFail()); App::singleton('menuNodeDataList', fn () => MenuNodeData::getCached()); // * Censor App::singleton('censor', fn () => new CensorWords()); $this->setPaymentCurrency(); } /** * Set formatters and payment currency * * @return void */ private function setPaymentCurrency(): void { // * Php Money currency (This is used everywhere), default is Euro App::singleton('phpMoneyCurrency', function () { return new Currency(config('money.currency')); }); // * Php Money formater (using app locale) App::singleton('phpMoneyFormatter', function () { // * Number format using app locale. $currencies = new ISOCurrencies(); $numberFormatter = new \NumberFormatter(\sprintf( '%s_%s', config('app.locale'), \strtoupper(config('app.locale')) ), \NumberFormatter::CURRENCY); return new IntlMoneyFormatter($numberFormatter, $currencies); }); } }