Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
88.24% |
15 / 17 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| AppServiceProvider | |
88.24% |
15 / 17 |
|
0.00% |
0 / 1 |
2.01 | |
0.00% |
0 / 1 |
| boot | |
88.24% |
15 / 17 |
|
0.00% |
0 / 1 |
2.01 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Providers; |
| 4 | |
| 5 | use Illuminate\Cache\RateLimiting\Limit; |
| 6 | use Illuminate\Http\Resources\Json\JsonResource; |
| 7 | use Illuminate\Support\Carbon; |
| 8 | use Illuminate\Support\Facades\App; |
| 9 | use Illuminate\Support\Facades\RateLimiter; |
| 10 | use Illuminate\Support\Facades\URL; |
| 11 | use Illuminate\Support\ServiceProvider; |
| 12 | |
| 13 | class AppServiceProvider extends ServiceProvider |
| 14 | { |
| 15 | /** |
| 16 | * Bootstrap any application services. |
| 17 | * |
| 18 | * @return void |
| 19 | */ |
| 20 | public function boot(): void |
| 21 | { |
| 22 | // * STATS jobs Rate Limiting. |
| 23 | RateLimiter::for('stats', function () { |
| 24 | return Limit::perMinute(60)->by(2); |
| 25 | }); |
| 26 | |
| 27 | // * EmpĂȘche l'encapsulation dans data. |
| 28 | JsonResource::withoutWrapping(); |
| 29 | |
| 30 | // * LOCAL HTTPS FIX. |
| 31 | URL::forceScheme('https'); |
| 32 | |
| 33 | // * HA PROXY FIX. |
| 34 | App::singleton('clientIp', function () { |
| 35 | if (config('app.env') === 'local') { |
| 36 | return request()->getClientIp(); |
| 37 | } else { |
| 38 | return request()->server('HTTP_X_FORWARDED_FOR') ?? |
| 39 | request()->getClientIp(); |
| 40 | } |
| 41 | }); |
| 42 | // * LOCAL FORCE eg: for Carbon. |
| 43 | setlocale(LC_ALL, \sprintf( |
| 44 | '%s_%s.UTF-8', |
| 45 | config('app.locale'), |
| 46 | \strtoupper(config('app.locale')) |
| 47 | )); |
| 48 | Carbon::setLocale(config('app.locale')); |
| 49 | } |
| 50 | } |