Passed
Push — master ( c21d64...956340 )
by Arthur
05:06
created

RouteServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Foundation\Providers;
4
5
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
6
use Illuminate\Support\Facades\Route;
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 = 'Foundation\Controllers';
18
19
    /**
20
     * Define your route model bindings, pattern filters, etc.
21
     *
22
     * @return void
23
     */
24 5
    public function boot()
25
    {
26 5
        parent::boot();
27 5
    }
28
29 5
    public function register()
30
    {
31 5
        $this->map();
32 5
        parent::register();
33 5
    }
34
35
    /**
36
     * Define the routes for the application.
37
     *
38
     * @return void
39
     */
40 5
    public function map()
41
    {
42 5
        $this->mapWebRoutes();
43 5
        $this->mapApiRoutes();
44 5
    }
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 5
    protected function mapWebRoutes()
54
    {
55 5
        $domain = strtolower(env('APP_URL'));
56 5
        $domain = str_replace('http://', '', $domain);
57 5
        $domain = str_replace('https://', '', $domain);
58 5
        Route::middleware('web')
59 5
            ->namespace($this->namespace)
60 5
            ->domain($domain)
61 5
            ->group(base_path('src/Foundation/Routes/web.php'));
62 5
    }
63
64
    /**
65
     * Define the "api" routes for the application.
66
     *
67
     * These routes are typically stateless.
68
     *
69
     * @return void
70
     */
71 5
    protected function mapApiRoutes()
72
    {
73 5
        $domain = strtolower(env('API_URL'));
74 5
        $domain = str_replace('http://', '', $domain);
75 5
        $domain = str_replace('https://', '', $domain);
76 5
        Route::middleware('api:noauth')
77 5
            ->namespace($this->namespace)
78 5
            ->domain($domain)
79 5
            ->group(base_path('src/Foundation/Routes/api.php'));
80 5
    }
81
}
82