2023-03-14 14:27:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
use Illuminate\Support\Facades\URL;
|
2025-02-18 13:45:23 +01:00
|
|
|
use Illuminate\Support\Facades\Vite;
|
2023-03-14 14:27:51 +01:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2025-02-18 13:45:23 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
2023-10-02 09:27:01 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2025-02-18 13:45:23 +01:00
|
|
|
use App\Providers\TelescopeServiceProvider as CustomTelescopeServiceProvider;
|
2023-03-14 14:27:51 +01:00
|
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*/
|
2025-02-18 13:45:23 +01:00
|
|
|
public function boot(): void
|
2023-03-14 14:27:51 +01:00
|
|
|
{
|
2025-02-18 13:45:23 +01:00
|
|
|
$this->app['request']->server->set('HTTPS', 'on');
|
|
|
|
|
Vite::prefetch(concurrency: 3);
|
|
|
|
|
|
2023-10-02 09:27:01 +00:00
|
|
|
Model::shouldBeStrict(!$this->app->environment('production'));
|
|
|
|
|
|
2023-03-14 14:27:51 +01:00
|
|
|
// * HTTPS FIX
|
|
|
|
|
URL::forceScheme('https');
|
|
|
|
|
|
|
|
|
|
// * HA PROXY FIX
|
|
|
|
|
App::singleton('clientIp', function () {
|
2025-02-18 13:45:23 +01:00
|
|
|
return (config('app.env') === 'local')
|
|
|
|
|
? request()->getClientIp()
|
|
|
|
|
: request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
|
2023-03-14 14:27:51 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// * LOCAL FORCE eg: for Carbon
|
|
|
|
|
setlocale(LC_ALL, \sprintf(
|
|
|
|
|
'%s_%s.UTF-8',
|
|
|
|
|
config('app.locale'),
|
|
|
|
|
\strtoupper(config('app.locale'))
|
|
|
|
|
));
|
|
|
|
|
Carbon::setLocale(config('app.locale'));
|
|
|
|
|
}
|
2025-02-18 13:45:23 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*/
|
|
|
|
|
public function register(): void
|
|
|
|
|
{
|
|
|
|
|
if ($this->app->environment('local')) {
|
|
|
|
|
$this->app->register(TelescopeServiceProvider::class);
|
|
|
|
|
$this->app->register(CustomTelescopeServiceProvider::class);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-14 14:27:51 +01:00
|
|
|
}
|