Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| AppServiceProvider | n/a |
0 / 0 |
n/a |
0 / 0 |
2 | n/a |
0 / 0 |
|||
| boot | n/a |
0 / 0 |
n/a |
0 / 0 |
2 | |||||
| 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 | /** |
| 14 | * @codeCoverageIgnore |
| 15 | */ |
| 16 | class AppServiceProvider extends ServiceProvider |
| 17 | { |
| 18 | /** |
| 19 | * Bootstrap any application services. |
| 20 | * |
| 21 | * @return void |
| 22 | */ |
| 23 | public function boot() |
| 24 | { |
| 25 | // * STATS jobs Rate Limiting. |
| 26 | RateLimiter::for('stats', function () { |
| 27 | return Limit::perMinute(60)->by(2); |
| 28 | }); |
| 29 | |
| 30 | // ! Important pourra etre retiré quand la V1 sera supprimé |
| 31 | // empeche l'encapsulation dans data |
| 32 | JsonResource::withoutWrapping(); |
| 33 | |
| 34 | // * LOCAL HTTPS FIX. |
| 35 | URL::forceScheme('https'); |
| 36 | |
| 37 | // * HA PROXY FIX. |
| 38 | App::singleton('clientIp', function () { |
| 39 | if (config('app.env') === 'local') { |
| 40 | return request()->getClientIp(); |
| 41 | } else { |
| 42 | return request()->server('HTTP_X_FORWARDED_FOR') ?? |
| 43 | request()->getClientIp(); |
| 44 | } |
| 45 | }); |
| 46 | // * LOCAL FORCE eg: for Carbon. |
| 47 | setlocale(LC_ALL, \sprintf( |
| 48 | '%s_%s.UTF-8', |
| 49 | config('app.locale'), |
| 50 | \strtoupper(config('app.locale')) |
| 51 | )); |
| 52 | Carbon::setLocale(config('app.locale')); |
| 53 | } |
| 54 | } |