ldc-com-app-bo/app/Providers/AppServiceProvider.php

43 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2023-03-14 14:57:03 +01:00
<?php
namespace App\Providers;
2023-07-13 08:34:54 +00:00
use Illuminate\Http\Resources\Json\JsonResource;
2023-03-14 14:57:03 +01:00
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\App;
2023-09-04 15:49:16 +02:00
use Illuminate\Support\Facades\URL;
2023-03-14 14:57:03 +01:00
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// * HTTPS FIX
2023-09-13 16:04:12 +02:00
URL::forceScheme('https');
2023-03-14 14:57:03 +01:00
// * 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'));
2023-07-13 08:34:54 +00:00
JsonResource::withoutWrapping();
2023-03-14 14:57:03 +01:00
}
}