RouteServiceProvider::mapApiRoutes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7
8
class RouteServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * This namespace is applied to your controller routes.
12
     *
13
     * In addition, it is set as the URL generator's root namespace.
14
     *
15
     * @var string
16
     */
17
    protected $namespace = 'App\Http\Controllers';
18
19
    /**
20
     * Define your route model bindings, pattern filters, etc.
21
     *
22
     * @return void
23
     */
24
    public function boot()
25
    {
26
        // See https://stackoverflow.com/a/7101148/1569360
27
        Route::pattern('subdomain', '^((?!local|dev|stage).)*$');
28
29
        parent::boot();
30
    }
31
32
    /**
33
     * Define the routes for the application.
34
     *
35
     * @return void
36
     */
37
    public function map()
38
    {
39
        $this->mapApiRoutes();
40
41
        $this->mapWebRoutes();
42
43
        //
44
    }
45
46
    /**
47
     * Define the "web" routes for the application.
48
     *
49
     * These routes all receive session state, CSRF protection, etc.
50
     *
51
     * @return void
52
     */
53
    protected function mapWebRoutes()
54
    {
55
        Route::middleware('web')
56
             ->namespace($this->namespace)
57
             ->group(base_path('routes/web.php'));
58
    }
59
60
    /**
61
     * Define the "api" routes for the application.
62
     *
63
     * These routes are typically stateless.
64
     *
65
     * @return void
66
     */
67
    protected function mapApiRoutes()
68
    {
69
        Route::prefix('api')
70
             ->middleware('api')
71
             ->namespace($this->namespace)
72
             ->group(base_path('routes/api.php'));
73
    }
74
}
75