Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RouteServiceProvider
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 boot
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace App\Providers;
4
5use Illuminate\Cache\RateLimiting\Limit;
6use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7use Illuminate\Http\Request;
8use Illuminate\Support\Facades\RateLimiter;
9use Illuminate\Support\Facades\Route;
10
11class RouteServiceProvider extends ServiceProvider
12{
13    /**
14     * The path to your application's "home" route.
15     *
16     * Typically, users are redirected here after authentication.
17     *
18     * @var string
19     */
20    public const HOME = '/home';
21
22    /**
23     * Define your route model bindings, pattern filters, and other route configuration.
24     */
25    public function boot(): void
26    {
27        RateLimiter::for('api', function (Request $request) {
28            return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
29        });
30
31        $this->routes(function () {
32            Route::middleware('api')
33                ->prefix('api')
34                ->group(base_path('routes/api.php'));
35
36            Route::middleware('web')
37                ->group(base_path('routes/web.php'));
38        });
39    }
40}