ldc-tousenselle/app/Providers/AppServiceProvider.php

41 lines
862 B
PHP
Raw Permalink Normal View History

2021-06-09 11:43:25 +02:00
<?php
namespace App\Providers;
2021-07-05 18:26:37 +02:00
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\URL;
2021-06-09 11:43:25 +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()
{
if (config('app.env') !== 'local') {
URL::forceScheme('https');
}
2021-07-05 18:26:37 +02:00
App::singleton('clientIp', function () {
if (config('app.env') === 'local') {
return request()->getClientIp();
} else {
return request()->server('HTTP_X_FORWARDED_FOR') ??
request()->getClientIp();
}
});
2021-06-09 11:43:25 +02:00
}
}