2020-11-18 10:23:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2026-06-26 09:33:50 +02:00
|
|
|
use App\Repositories\EloquentSiteRepository;
|
|
|
|
|
use App\Repositories\SiteRepository;
|
2023-08-14 09:23:39 +00:00
|
|
|
use Illuminate\Support\Facades\App;
|
2021-06-18 15:39:19 +02:00
|
|
|
use Illuminate\Support\Facades\URL;
|
2020-11-18 10:23:51 +01:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2026-06-26 09:33:50 +02:00
|
|
|
use Override;
|
2020-11-18 10:23:51 +01:00
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
2026-06-26 09:33:50 +02:00
|
|
|
#[Override]
|
|
|
|
|
public function register()
|
|
|
|
|
{
|
|
|
|
|
$this->app->singleton(
|
|
|
|
|
SiteRepository::class,
|
|
|
|
|
fn() => new EloquentSiteRepository()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-18 10:23:51 +01:00
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function boot()
|
|
|
|
|
{
|
2023-08-14 09:23:39 +00:00
|
|
|
// * HTTPS FIX
|
2022-06-09 12:03:49 +02:00
|
|
|
URL::forceScheme('https');
|
2021-05-21 16:02:29 +02:00
|
|
|
|
2022-08-30 13:21:07 +00:00
|
|
|
// * HA PROXY FIX
|
2023-08-14 09:23:39 +00:00
|
|
|
App::singleton('clientIp', function () {
|
2022-08-30 13:21:07 +00:00
|
|
|
if (config('app.env') === 'local') {
|
|
|
|
|
return request()->getClientIp();
|
2023-08-14 09:23:39 +00:00
|
|
|
} else {
|
|
|
|
|
return request()->server('HTTP_X_FORWARDED_FOR') ??
|
2026-06-26 09:33:50 +02:00
|
|
|
request()->getClientIp();
|
2022-08-30 13:21:07 +00:00
|
|
|
}
|
|
|
|
|
});
|
2022-04-26 12:15:31 +02:00
|
|
|
|
2023-08-14 09:23:39 +00:00
|
|
|
// * LOCAL FORCE eg: for Carbon
|
|
|
|
|
setlocale(LC_ALL, \sprintf(
|
|
|
|
|
'%s_%s.UTF-8',
|
|
|
|
|
config('app.locale'),
|
|
|
|
|
\strtoupper(config('app.locale'))
|
|
|
|
|
));
|
2020-11-18 10:23:51 +01:00
|
|
|
}
|
|
|
|
|
}
|