RouteServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
6
use Ramsey\Uuid\Uuid;
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
        \Route::pattern('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
27
28
        \Route::bind('uuid', function($value) {
29
            return Uuid::fromString($value);
30
        });
31
32
        parent::boot();
33
    }
34
35
    /**
36
     * Define the routes for the application.
37
     *
38
     * @return void
39
     */
40
    public function map()
41
    {
42
        $this->mapApiRoutes();
43
44
        $this->mapWebRoutes();
45
46
        //
47
    }
48
49
    /**
50
     * Define the "web" routes for the application.
51
     *
52
     * These routes all receive session state, CSRF protection, etc.
53
     *
54
     * @return void
55
     */
56
    protected function mapWebRoutes()
57
    {
58
        \Route::middleware('web')
59
             ->namespace($this->namespace)
60
             ->group(base_path('routes/web.php'));
61
    }
62
63
    /**
64
     * Define the "api" routes for the application.
65
     *
66
     * These routes are typically stateless.
67
     *
68
     * @return void
69
     */
70
    protected function mapApiRoutes()
71
    {
72
        \Route::prefix('api')
73
             ->middleware('api')
74
             ->namespace($this->namespace)
75
             ->group(base_path('routes/api.php'));
76
    }
77
}
78