ldc-le-gaulois-pro/app/Providers/AppServiceProvider.php
Vincent BRIDIER 35dcaacefc
PHPCS
2023-01-05 18:33:53 +01:00

87 lines
2.6 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Carbon;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
URL::forceScheme('https');
// phpcs:ignore FIXME: A ENLEVER
View::share('ranges', (object)[
0 => [
'label' => 'Volailles crue',
'slug' => Str::slug('Volailles crue'),
'classColor' => 'blue'
],
1 => [
'label' => 'Elaborés de volaille crus',
'slug' => Str::slug('Elaborés de volaille crus'),
'classColor' => 'red'
],
2 => [
'label' => 'Elaborés de volaille cuits',
'slug' => Str::slug('Elaborés de volaille cuits'),
'classColor' => 'orange'
],
3 => [
'label' => 'Volailles certifiées',
'slug' => Str::slug('Volailles certifiées'),
'classColor' => 'green'
],
4 => [
'label' => 'Volailles Bien-être animal',
'slug' => Str::slug('Volailles Bien-être animal'),
'classColor' => 'deep-green'
]
]);
// * 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();
});
}
}