Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       11 / 11  | 
               | 
       100.00%  | 
       2 / 2  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| RouteServiceProvider |         | 
       100.00%  | 
       11 / 11  | 
               | 
       100.00%  | 
       2 / 2  | 
       3 |         | 
       100.00%  | 
       1 / 1  | 
      
| boot |         | 
       100.00%  | 
       9 / 9  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| configureRateLimiting |         | 
       100.00%  | 
       2 / 2  | 
               | 
       100.00%  | 
       1 / 1  | 
       2 | |||
| 1 | <?php | 
| 2 | |
| 3 | namespace App\Providers; | 
| 4 | |
| 5 | use Illuminate\Cache\RateLimiting\Limit; | 
| 6 | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | 
| 7 | use Illuminate\Http\Request; | 
| 8 | use Illuminate\Support\Facades\RateLimiter; | 
| 9 | use Illuminate\Support\Facades\Route; | 
| 10 | |
| 11 | class RouteServiceProvider extends ServiceProvider | 
| 12 | { | 
| 13 | /** | 
| 14 | * The path to the "home" route for your application. | 
| 15 | * | 
| 16 | * This is used by Laravel authentication to redirect users after login. | 
| 17 | * | 
| 18 | * @var string | 
| 19 | */ | 
| 20 | public const HOME = '/home'; | 
| 21 | |
| 22 | /** | 
| 23 | * The controller namespace for the application. | 
| 24 | * | 
| 25 | * When present, controller route declarations will automatically be prefixed with this namespace. | 
| 26 | * | 
| 27 | */ | 
| 28 | // protected $namespace = 'App\\Http\\Controllers'; | 
| 29 | |
| 30 | /** | 
| 31 | * Define your route model bindings, pattern filters, etc. | 
| 32 | * | 
| 33 | * @return void | 
| 34 | */ | 
| 35 | public function boot() | 
| 36 | { | 
| 37 | $this->configureRateLimiting(); | 
| 38 | |
| 39 | $this->routes(function () { | 
| 40 | Route::prefix('api') | 
| 41 | ->middleware('api') | 
| 42 | ->namespace($this->namespace) | 
| 43 | ->group(base_path('routes/api.php')); | 
| 44 | |
| 45 | Route::middleware('web') | 
| 46 | ->namespace($this->namespace) | 
| 47 | ->group(base_path('routes/web.php')); | 
| 48 | }); | 
| 49 | } | 
| 50 | |
| 51 | /** | 
| 52 | * Configure the rate limiters for the application. | 
| 53 | * | 
| 54 | * @return void | 
| 55 | */ | 
| 56 | protected function configureRateLimiting() | 
| 57 | { | 
| 58 | RateLimiter::for('api', function (Request $request) { | 
| 59 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); | 
| 60 | }); | 
| 61 | } | 
| 62 | } |