RouteServiceProvider.php 2.24 KB
Newer Older
1
2
3
4
5
<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
Jacob Priddy's avatar
Jacob Priddy committed
6
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7

Jacob Priddy's avatar
Jacob Priddy committed
8
9
class RouteServiceProvider extends ServiceProvider
{
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * The path to the "home" route for your application.
     *
     * @var string
     */
24
    public const HOME = '/';
25
26
27
28
29
30

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
31
32
    public function boot()
    {
33
34
35
36
37
38
39
40
        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
41
42
    public function map()
    {
Jacob Priddy's avatar
Jacob Priddy committed
43
44
        $this->mapDoorRoutes();

45
46
47
        $this->mapApiRoutes();

        $this->mapWebRoutes();
48
49

        $this->mapFrontendRoutes();
50
51
52
53
54
55
56
57
58
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
59
60
    protected function mapWebRoutes(): void
    {
61
62
63
64
        Route::prefix('api')
            ->middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/web.php'));
65
66
67
68
69
70
71
72
73
    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
74
75
    protected function mapApiRoutes(): void
    {
76
77
78
79
        Route::prefix('api')
            ->middleware('api')
            ->namespace($this->namespace)
            ->group(base_path('routes/api.php'));
80
    }
Jacob Priddy's avatar
Jacob Priddy committed
81
82
83
84
85
86

    /**
     * Define the routes doors can and do use
     *
     * @return void
     */
Jacob Priddy's avatar
Jacob Priddy committed
87
88
    protected function mapDoorRoutes(): void
    {
89
90
91
92
        Route::prefix('api/door')
            ->middleware('door')
            ->namespace($this->namespace)
            ->group(base_path('routes/door.php'));
Jacob Priddy's avatar
Jacob Priddy committed
93
    }
94
95
96
97
98
99

    /**
     * Define the routes the frontend has
     */
    protected function mapFrontendRoutes(): void
    {
100
        Route::middleware('web')
101
102
103
            ->namespace($this->namespace)
            ->group(base_path('routes/frontend.php'));
    }
104
}