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;
|
2021-06-16 17:56:38 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2021-06-16 17:56:38 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|