ldc-le-gaulois-pro/app/Providers/AppServiceProvider.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2022-08-31 09:18:53 +00:00
<?php
namespace App\Providers;
2024-02-05 09:33:08 +01:00
use Illuminate\Database\Eloquent\Model;
2022-11-29 14:47:07 +01:00
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
2022-09-08 11:36:15 +02:00
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
2022-08-31 09:18:53 +00:00
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
2024-02-05 09:33:08 +01:00
Model::shouldBeStrict(!$this->app->environment('production'));
// * HTTPS FIX
2022-09-08 11:36:15 +02:00
URL::forceScheme('https');
2022-10-05 15:31:59 +02:00
2022-11-29 14:47:07 +01:00
// * HA PROXY FIX
App::singleton('clientIp', function () {
2022-11-29 14:47:07 +01:00
if (config('app.env') === 'local') {
return request()->getClientIp();
} else {
return request()->server('HTTP_X_FORWARDED_FOR') ??
request()->getClientIp();
2022-11-29 14:47:07 +01: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'));
2022-08-31 09:18:53 +00:00
}
}