- Make all tests pass Client (V4),CRMV2,CRMV4 - Simplify client submodule path - Move App_url to .env.testing
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Carbon;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// * STATS jobs Rate Limiting.
|
|
RateLimiter::for('stats', function () {
|
|
return Limit::perMinute(60)->by(2);
|
|
});
|
|
|
|
// Empêche l'encapsulation dans data.
|
|
JsonResource::withoutWrapping();
|
|
|
|
// * LOCAL HTTPS FIX.
|
|
URL::forceScheme('https');
|
|
|
|
// * HA PROXY FIX.
|
|
App::singleton('clientIp', function () {
|
|
if (config('app.env') === 'local') {
|
|
return request()->getClientIp();
|
|
} else {
|
|
return request()->server('HTTP_X_FORWARDED_FOR') ??
|
|
request()->getClientIp();
|
|
}
|
|
});
|
|
// * 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'));
|
|
}
|
|
}
|