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

57 lines
1.5 KiB
PHP
Raw Normal View History

2022-08-31 09:18:53 +00:00
<?php
namespace App\Providers;
2022-11-29 14:47:07 +01:00
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Carbon;
2022-08-31 09:18:53 +00:00
use Illuminate\Support\ServiceProvider;
2022-09-08 11:36:15 +02:00
use Illuminate\Support\Facades\URL;
2022-08-31 09:18:53 +00:00
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
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
// * LOCAL FORCE eg: for Carbon
// * Remove numeric to prevent float seperator to breaking numeric transactions
\collect([\LC_TIME, \LC_MESSAGES, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY])
->map(function ($contant) {
setlocale(
$contant,
\sprintf(
'%s_%s.UTF-8',
config('app.locale'),
\strtoupper(config('app.locale'))
)
);
});
Carbon::setLocale(config('app.locale'));
// * Force bootstrap paginator with tooltips.
Paginator::defaultView('bo.modules.pagination');
// * HA PROXY FIX
app()->singleton('clientIp', function () {
if (config('app.env') === 'local') {
return request()->getClientIp();
}
return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
});
2022-08-31 09:18:53 +00:00
}
}