43 lines
1,016 B
PHP
43 lines
1,016 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use App\Enums\Country;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
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');
|
|
|
|
// * 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());
|
|
}
|
|
}
|