2020-10-21 15:26:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2023-11-23 17:31:28 +01:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Support\Carbon;
|
2022-01-10 16:29:33 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
|
use Illuminate\Support\Facades\URL;
|
2023-08-21 10:15:14 +00:00
|
|
|
use Illuminate\Support\Pluralizer;
|
2020-10-21 15:26:21 +02:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2025-04-18 16:59:57 +02:00
|
|
|
public function boot(): void
|
2020-10-21 15:26:21 +02:00
|
|
|
{
|
2023-11-23 17:31:28 +01:00
|
|
|
Model::shouldBeStrict(!$this->app->environment('production'));
|
|
|
|
|
|
|
|
|
|
// * HTTPS FIX
|
2022-05-02 14:30:59 +02:00
|
|
|
URL::forceScheme('https');
|
2022-08-11 10:03:16 +02:00
|
|
|
|
2022-01-10 16:29:33 +01:00
|
|
|
// * HA PROXY FIX.
|
|
|
|
|
App::singleton('clientIp', function () {
|
2023-08-21 10:22:07 +02:00
|
|
|
if (config('app.env') === 'local') {
|
2023-11-30 14:46:08 +01:00
|
|
|
return \IPLib\Factory::parseAddressString(request()->getClientIp());
|
2022-01-10 16:29:33 +01:00
|
|
|
} else {
|
2023-11-30 14:46:08 +01:00
|
|
|
return \IPLib\Factory::parseAddressString(
|
|
|
|
|
request()->server('HTTP_X_FORWARDED_FOR') ??
|
|
|
|
|
request()->getClientIp()
|
|
|
|
|
);
|
2022-01-10 16:29:33 +01:00
|
|
|
}
|
|
|
|
|
});
|
2023-08-21 10:22:07 +02:00
|
|
|
|
2023-11-23 17:31:28 +01:00
|
|
|
// * LOCAL FORCE eg: for Carbon
|
2022-01-10 16:29:33 +01:00
|
|
|
setlocale(LC_ALL, \sprintf(
|
|
|
|
|
'%s_%s.UTF-8',
|
|
|
|
|
config('app.locale'),
|
|
|
|
|
\strtoupper(config('app.locale'))
|
|
|
|
|
));
|
2023-11-23 17:31:28 +01:00
|
|
|
Carbon::setLocale(config('app.locale'));
|
2023-08-21 10:15:14 +00:00
|
|
|
Pluralizer::useLanguage('french');
|
2020-10-21 15:26:21 +02:00
|
|
|
}
|
|
|
|
|
}
|