1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace App\Providers; |
6
|
|
|
|
7
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
8
|
|
|
use Illuminate\Routing\Router; |
9
|
|
|
|
10
|
|
|
final class RouteServiceProvider extends ServiceProvider |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* This namespace is applied to your controller routes. |
14
|
|
|
* |
15
|
|
|
* In addition, it is set as the URL generator's root namespace. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $namespace = 'App\Http\Controllers'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Define the routes for the application. |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException |
26
|
34 |
|
*/ |
27
|
|
|
public function map(): void |
28
|
34 |
|
{ |
29
|
34 |
|
$router = $this->app->make(Router::class); |
30
|
|
|
|
31
|
|
|
$this->mapApiRoutes($router); |
32
|
|
|
|
33
|
|
|
$this->mapWebRoutes($router); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
34 |
|
* Define the "web" routes for the application. |
38
|
|
|
* |
39
|
34 |
|
* These routes all receive session state, CSRF protection, etc. |
40
|
|
|
* |
41
|
34 |
|
* @param \Illuminate\Routing\Router $router |
42
|
|
|
* @return void |
43
|
34 |
|
*/ |
44
|
34 |
|
protected function mapWebRoutes(Router $router): void |
45
|
|
|
{ |
46
|
|
|
$router->middleware('web') |
47
|
|
|
->namespace($this->namespace) |
48
|
|
|
->group(base_path('routes/web.php')); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Define the "api" routes for the application. |
53
|
|
|
* |
54
|
34 |
|
* These routes are typically stateless. |
55
|
|
|
* |
56
|
34 |
|
* @param \Illuminate\Routing\Router $router |
57
|
34 |
|
* @return void |
58
|
34 |
|
*/ |
59
|
34 |
|
protected function mapApiRoutes(Router $router): void |
60
|
|
|
{ |
61
|
|
|
$router->middleware('api') |
62
|
|
|
->namespace($this->namespace) |
63
|
|
|
->group(base_path('routes/api.php')); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|