ldc-startcoq/app/Providers/AppServiceProvider.php

43 lines
1 KiB
PHP
Raw Permalink Normal View History

2023-02-20 10:01:53 +01:00
<?php
namespace App\Providers;
2023-06-21 10:24:56 +00:00
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\URL;
2023-02-20 10:01:53 +01:00
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
2023-09-11 12:22:32 +02:00
*
* @return void
2023-02-20 10:01:53 +01:00
*/
public function boot(): void
{
2023-06-21 10:24:56 +00:00
// * LOCAL 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') ??
2023-09-11 12:22:32 +02:00
request()->getClientIp();
2023-06-21 10:24:56 +00:00
}
});
// * 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'));
2023-02-20 10:01:53 +01:00
}
}