RouteServiceProvider.php 2.54 KB
Newer Older
Dominik Hebeler's avatar
Dominik Hebeler committed
1
2
3
4
5
<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
6
use Illuminate\Support\Facades\Route;
Dominik Hebeler's avatar
Dominik Hebeler committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

class RouteServiceProvider extends ServiceProvider
{
    /**
     * 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';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
24
    public function boot()
Dominik Hebeler's avatar
Dominik Hebeler committed
25
26
27
    {
        //

28
        parent::boot();
Dominik Hebeler's avatar
Dominik Hebeler committed
29
30
31
32
33
34
35
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
36
    public function map()
Dominik Hebeler's avatar
Dominik Hebeler committed
37
    {
38
39
40
        $this->mapApiRoutes();

        $this->mapWebRoutes();
Dominik Hebeler's avatar
Dominik Hebeler committed
41

Dominik Hebeler's avatar
Dominik Hebeler committed
42
43
        $this->mapSessionRoutes();

44
45
        $this->mapEnableCookieRoutes();

Dominik Hebeler's avatar
Dominik Hebeler committed
46
47
48
49
50
51
52
53
54
55
        //
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => 'web',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/web.php');
        });
    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
Dominik Hebeler's avatar
Dominik Hebeler committed
74
    {
75
76
77
78
        Route::group([
            'middleware' => 'api',
            'namespace' => $this->namespace,
            'prefix' => 'api',
Dominik Hebeler's avatar
Dominik Hebeler committed
79
        ], function ($router) {
80
            require base_path('routes/api.php');
Dominik Hebeler's avatar
Dominik Hebeler committed
81
82
        });
    }
Dominik Hebeler's avatar
Dominik Hebeler committed
83
84
85
86
87
88
89
90

    /**
     * Define the "session" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
    protected function mapEnableCookieRoutes()
    {
        Route::group([
            'middleware' => 'enableCookies',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/cookie.php');
        });
    }

    /**
     * Define the "session" routes for the application.
     *
     * These routes can all set cookies.
     *
     * @return void
     */
Dominik Hebeler's avatar
Dominik Hebeler committed
108
109
110
111
112
113
114
115
116
    protected function mapSessionRoutes()
    {
        Route::group([
            'middleware' => 'session',
            'namespace' => $this->namespace,
        ], function ($router) {
            require base_path('routes/session.php');
        });
    }
Dominik Hebeler's avatar
Dominik Hebeler committed
117
}