app->environment('production')); // * HTTPS FIX URL::forceScheme('https'); // * HA PROXY FIX App::singleton('clientIp', function () { return (config('app.env') === 'local') ? request()->getClientIp() : 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()); // * Axepta $this->app->singleton(AxeptaPaymentService::class, function () { $logger = resolve(LoggerInterface::class); $config = new AxeptaConfig( endpoint: Config::string('axepta.endpoint'), merchantId: Config::string('axepta.merchantId'), apiKey: Config::string('axepta.apiKey'), hmac: Config::string('axepta.hmac') ); $gateway = new AxeptaApiGateway($config); $tokenManager = new AxeptaTokenManager($gateway, $config); $signatureVerifier = new AxeptaSignatureVerifier($config, $logger); return new AxeptaPaymentService( $logger, $config, $gateway, $tokenManager, $signatureVerifier ); }); $this->setPaymentCurrency(); // * BLADE DIRECTIVES Blade::if('isExport', function () { return request()->routeIs('fo.*.export'); }); } /** * Register any application services. */ public function register(): void { if ($this->app->environment('local')) { $this->app->register(TelescopeServiceProvider::class); $this->app->register(CustomTelescopeServiceProvider::class); } } /** * Set formatters and payment currency. */ 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); }); } }