Created
March 10, 2016 09:03
-
-
Save IsraelOrtuno/7d6e5c19756bd99f6f4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Routing\Router; | |
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | |
class RouteServiceProvider extends ServiceProvider | |
{ | |
/** | |
* This namespace is applied to the controller routes in your routes file. | |
* | |
* In addition, it is set as the URL generator's root namespace. | |
* | |
* @var string | |
*/ | |
protected $namespace = [ | |
'web' => 'App\Http\Controllers', | |
'api' => 'App\Api\Controllers' | |
]; | |
/** | |
* Routing patterns. | |
* | |
* @var array | |
*/ | |
protected $patterns = [ | |
'attachmentType' => 'install|maintenance' | |
]; | |
/** | |
* Define your route model bindings, pattern filters, etc. | |
* | |
* @param \Illuminate\Routing\Router $router | |
* @return void | |
*/ | |
public function boot(Router $router) | |
{ | |
// Registering all the patterns available | |
$router->patterns($this->patterns); | |
parent::boot($router); | |
} | |
/** | |
* Define the routes for the application. | |
* | |
* @param \Illuminate\Routing\Router $router | |
* @return void | |
*/ | |
public function map(Router $router) | |
{ | |
// Will include every route file found at Http/Routes. If any of these | |
// files have set a namespace, it will be relative to the namespace | |
// value preset in this provider. We are now organizing better. | |
$router->group(['namespace' => $this->namespace['web'], 'middleware' => 'web'], function ($router) { | |
foreach (\File::allFiles(app_path('Http/Routes')) as $partial) { | |
require $partial; | |
} | |
}); | |
$router->group(['namespace' => $this->namespace['api'], 'prefix' => 'api', 'middleware' => 'api'], function ($router) { | |
foreach (\File::allFiles(app_path('Api/Routes')) as $partial) { | |
require $partial; | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment