ldc-portsalaries/app/Providers/AppServiceProvider.php

54 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2021-04-22 17:22:26 +02:00
<?php
namespace App\Providers;
2021-05-08 06:50:19 +02:00
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Carbon;
2021-09-06 11:44:15 +02:00
use Illuminate\Support\Facades\App;
2021-05-08 06:50:19 +02:00
use Illuminate\Support\Facades\URL;
2021-04-22 17:22:26 +02:00
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
2021-09-06 11:44:15 +02:00
// LOCAL HTTPS FIX
2022-06-17 10:16:55 +02:00
URL::forceScheme('https');
2021-09-06 11:44:15 +02: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();
}
});
2021-11-05 16:52:00 +01:00
// LOCAL FORCE eg: for Carbon
2021-09-06 11:44:15 +02:00
setlocale(LC_ALL, \sprintf(
'%s_%s.UTF-8',
config('app.locale'),
\strtoupper(config('app.locale'))
));
Carbon::setLocale(config('app.locale'));
// FORCE BOOTSTRAP PAGINATOR
2021-05-08 06:50:19 +02:00
if (!app()->runningInConsole()) {
Paginator::useBootstrap();
}
2021-04-22 17:22:26 +02:00
}
}