Skip to content

Instantly share code, notes, and snippets.

@yashbarot
Created November 24, 2016 06:06
Show Gist options
  • Select an option

  • Save yashbarot/e742a1ad2cd9ffdb23601e9bfe5574e5 to your computer and use it in GitHub Desktop.

Select an option

Save yashbarot/e742a1ad2cd9ffdb23601e9bfe5574e5 to your computer and use it in GitHub Desktop.
Load Routes from Routes Folder
<?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