ldc-doux/app/Providers/AppServiceProvider.php

44 lines
1,016 B
PHP
Raw Normal View History

2021-11-18 14:36:06 +01:00
<?php
namespace App\Providers;
2022-02-04 18:35:33 +01:00
use Illuminate\Support\Facades\URL;
2021-11-18 14:36:06 +01:00
use Illuminate\Support\ServiceProvider;
2023-06-26 08:52:32 +00:00
use App\Enums\Country;
use Illuminate\Support\Facades\Cache;
2021-11-18 14:36:06 +01:00
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
2022-05-10 09:36:01 +02:00
URL::forceScheme('https');
2023-06-26 08:52:32 +00:00
// * HA PROXY FIX
app()->singleton('clientIp', function () {
if (config('app.env') === 'local') {
return request()->getClientIp();
}
return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
});
$listCountries = Cache::remember('listCountries', 60, function () {
return Country::toArray();
});
view()->share('availableCountries', $listCountries ?? Country::toArray());
2021-11-18 14:36:06 +01:00
}
}