Created
November 24, 2016 06:06
-
-
Save yashbarot/e742a1ad2cd9ffdb23601e9bfe5574e5 to your computer and use it in GitHub Desktop.
Load Routes from Routes Folder
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 = 'App\Http\Controllers'; | |
| /** | |
| * Define your route model bindings, pattern filters, etc. | |
| * | |
| * @param \Illuminate\Routing\Router $router | |
| * @return void | |
| */ | |
| public function boot(Router $router) | |
| { | |
| // | |
| parent::boot($router); | |
| } | |
| /** | |
| * Define the routes for the application. | |
| * | |
| * @param \Illuminate\Routing\Router $router | |
| * @return void | |
| */ | |
| public function map(Router $router) | |
| { | |
| $router->group(['namespace' => $this->namespace], function ($router) { | |
| require app_path('Http/routes.php'); | |
| }); | |
| $router->group(['namespace' => $this->namespace, 'prefix' => 'v1/api', 'middleware' => ['jwt.auth']], function ($router) { | |
| $path = app_path('Routes/*.php'); | |
| foreach (glob($path) as $filename) { | |
| require $filename; | |
| } | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment