RouteServiceProvider::configureRateLimiting()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 6
rs 10
c 0
b 0
f 0
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
    public const HOME = '/dashboard';
14
15
    /**
16
     * Define your route model bindings, pattern filters, etc.
17
     */
18
    public function boot()
19
    {
20
        $this->configureRateLimiting();
21
22
        $this->routes(function()
23
        {
24 906
            //  Basic Login and Logout Routes
25
            Route::middleware('web')
26 906
                ->namespace($this->namespace)
27 906
                ->group(base_path('routes/auth.php'));
28
29
            //  System Administration Routes
30
            Route::middleware('web')
31
                ->namespace($this->namespace)
32
                ->group(base_path('routes/admin.php'));
33
34 906
            //  Basic Authenticated Routes
35
            Route::middleware('web')
36 906
                ->namespace($this->namespace)
37
                ->group(base_path('routes/web.php'));
38 906
39
            //  Customer Routes
40
            Route::middleware('web')
41 906
                ->namespace($this->namespace)
42
                ->group(base_path('routes/cust.php'));
43
44
            //  Equipment Routes
45
            Route::middleware('web')
46
                ->namespace($this->namespace)
47
                ->group(base_path('routes/equip.php'));
48
49
            //  Tech Tip Routes
50 906
            Route::middleware('web')
51
                ->namespace($this->namespace)
52 906
                ->group(base_path('routes/tips.php'));
53 906
        });
54 906
    }
55 906
56
    /**
57
     * Configure the rate limiters for the application.
58
     */
59
    protected function configureRateLimiting()
60
    {
61
        RateLimiter::for('api', function(Request $request) {
62
            return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
63
        });
64 906
    }
65
}
66