|
1
|
|
|
<?php namespace Distilleries\Expendable; |
|
2
|
|
|
|
|
3
|
|
|
use Distilleries\Expendable\Http\Router\Router; |
|
4
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
|
5
|
|
|
|
|
6
|
|
|
class ExpendableRouteServiceProvider extends ServiceProvider |
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
protected $router; |
|
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 = 'Distilleries\Expendable\Http\Controllers'; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Define your route model bindings, pattern filters, etc. |
|
23
|
668 |
|
* |
|
24
|
|
|
* @return void |
|
25
|
668 |
|
*/ |
|
26
|
|
|
public function boot() |
|
27
|
501 |
|
{ |
|
28
|
|
|
parent::boot(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Define the routes for the application. |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
public function map() |
|
37
|
668 |
|
{ |
|
38
|
|
|
$this->mapWebRoutes(); |
|
39
|
668 |
|
|
|
40
|
668 |
|
$this->mapApiRoutes(); |
|
41
|
501 |
|
|
|
42
|
|
|
// |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Register the service provider. |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
public function register() |
|
53
|
|
|
{ |
|
54
|
|
|
|
|
55
|
|
|
$this->registerRouter(); |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
protected function registerRouter(){ |
|
61
|
|
|
|
|
62
|
|
|
$this->app['router'] = $this->app->share(function($app) |
|
63
|
|
|
{ |
|
64
|
|
|
$router = new Router($app['events'], $app); |
|
65
|
|
|
|
|
66
|
|
|
return $router; |
|
67
|
|
|
}); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Define the "web" routes for the application. |
|
73
|
|
|
* |
|
74
|
|
|
* These routes all receive session state, CSRF protection, etc. |
|
75
|
|
|
* |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function mapWebRoutes() |
|
79
|
|
|
{ |
|
80
|
|
|
|
|
81
|
|
|
\Route::group([ |
|
82
|
|
|
'middleware' => 'web', |
|
83
|
|
|
'namespace' => $this->namespace, |
|
84
|
|
|
], function ($router) { |
|
85
|
|
|
|
|
86
|
|
|
require __DIR__ . '/../routes/web.php'; |
|
87
|
|
|
}); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Define the "api" routes for the application. |
|
92
|
|
|
* |
|
93
|
|
|
* These routes are typically stateless. |
|
94
|
|
|
* |
|
95
|
|
|
* @return void |
|
96
|
|
|
*/ |
|
97
|
|
|
protected function mapApiRoutes() |
|
98
|
|
|
{ |
|
99
|
|
|
\Route::group([ |
|
100
|
|
|
'middleware' => 'api', |
|
101
|
|
|
'namespace' => $this->namespace, |
|
102
|
|
|
'prefix' => 'api', |
|
103
|
|
|
], function ($router) { |
|
104
|
|
|
require __DIR__ . '/../routes/api.php'; |
|
105
|
|
|
}); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|