1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Foundation\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
6
|
|
|
use Illuminate\Support\Facades\Route; |
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 = 'Foundation\Controllers'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Define your route model bindings, pattern filters, etc. |
21
|
|
|
* |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
41 |
|
public function boot() |
25
|
|
|
{ |
26
|
41 |
|
parent::boot(); |
27
|
41 |
|
} |
28
|
|
|
|
29
|
41 |
|
public function register() |
30
|
|
|
{ |
31
|
41 |
|
$this->map(); |
32
|
41 |
|
parent::register(); |
33
|
41 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Define the routes for the application. |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
41 |
|
public function map() |
41
|
|
|
{ |
42
|
41 |
|
$this->mapWebRoutes(); |
43
|
41 |
|
$this->mapApiRoutes(); |
44
|
41 |
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Define the "web" routes for the application. |
48
|
|
|
* |
49
|
|
|
* These routes all receive session state, CSRF protection, etc. |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
41 |
|
protected function mapWebRoutes() |
54
|
|
|
{ |
55
|
41 |
|
$domain = strtolower(env('APP_URL')); |
56
|
41 |
|
$domain = str_replace('http://', '', $domain); |
57
|
41 |
|
$domain = str_replace('https://', '', $domain); |
58
|
41 |
|
Route::middleware('web') |
59
|
41 |
|
->namespace($this->namespace) |
60
|
41 |
|
->domain($domain) |
61
|
41 |
|
->group(base_path('src/Foundation/Routes/web.php')); |
62
|
41 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Define the "api" routes for the application. |
66
|
|
|
* |
67
|
|
|
* These routes are typically stateless. |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
41 |
|
protected function mapApiRoutes() |
72
|
|
|
{ |
73
|
41 |
|
$domain = strtolower(env('API_URL')); |
74
|
41 |
|
$domain = str_replace('http://', '', $domain); |
75
|
41 |
|
$domain = str_replace('https://', '', $domain); |
76
|
41 |
|
Route::middleware('api:noauth') |
77
|
41 |
|
->namespace($this->namespace) |
78
|
41 |
|
->domain($domain) |
79
|
41 |
|
->group(base_path('src/Foundation/Routes/api.php')); |
80
|
41 |
|
} |
81
|
|
|
} |
82
|
|
|
|