Passed
Push — develop ( 350d61...88e848 )
by Septianata
03:01
created

RouteServiceProvider::mapWebBotManCommands()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
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 = '/';
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
     * @var string|null
28
     */
29
    // protected $namespace = 'App\\Http\\Controllers';
30
31
    /**
32
     * Define your route model bindings, pattern filters, etc.
33
     *
34
     * @return void
35
     */
36 1
    public function boot()
37
    {
38 1
        $this->configureRateLimiting();
39
40 1
        $this->routes(function () {
41 1
            Route::prefix('api')
42 1
                ->middleware('api')
43 1
                ->namespace($this->namespace)
44 1
                ->group(base_path('routes/api.php'));
45
46 1
            Route::middleware('web')
47 1
                ->namespace($this->namespace)
48 1
                ->group(base_path('routes/web.php'));
49
50 1
            $this->mapWebBotManCommands();
51 1
        });
52
53 1
        $this->mapBotManCommands();
54
55 1
    }
56
57
    /**
58
     * Configure the rate limiters for the application.
59
     *
60
     * @return void
61
     */
62 1
    protected function configureRateLimiting()
63
    {
64 1
        RateLimiter::for('api', function (Request $request) {
65
            return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
66 1
        });
67 1
    }
68
69
    /**
70
     * Defines the BotMan "hears" commands.
71
     *
72
     * @return void
73
     */
74 1
    protected function mapBotManCommands()
75
    {
76 1
        require base_path('routes/botman.php');
77 1
    }
78
79
    /**
80
     * Defines the BotMan web route.
81
     *
82
     * @return void
83
     */
84 1
    protected function mapWebBotManCommands()
85
    {
86 1
        Route::middleware('web_without_csrf')
87 1
            ->prefix('/botman')
88 1
            ->namespace($this->namespace)
89 1
            ->group(base_path('routes/web-botman.php'));
90 1
    }
91
}
92