diff --git a/modules/Sample/Http/routes.php b/modules/Sample/Http/routes.php index 24b216e5..30b5171e 100644 --- a/modules/Sample/Http/routes.php +++ b/modules/Sample/Http/routes.php @@ -1,14 +1,8 @@ 'sample.', - 'prefix' => 'sample', - 'middleware' => [ - 'web', - 'role:admin|user' # leave blank for public - ], - 'namespace' => 'Modules\Sample\Http\Controllers' -], function() { +Route::group(['middleware' => [ + 'role:admin|user' # leave blank to make this public +]], function() { # all your routes are prefixed with the above prefix # e.g. yoursite.com/sample diff --git a/modules/Sample/Providers/SampleServiceProvider.php b/modules/Sample/Providers/SampleServiceProvider.php index 2836dfa1..c4b98cb1 100644 --- a/modules/Sample/Providers/SampleServiceProvider.php +++ b/modules/Sample/Providers/SampleServiceProvider.php @@ -4,6 +4,8 @@ namespace Modules\Sample\Providers; use Illuminate\Support\ServiceProvider; use Illuminate\Database\Eloquent\Factory; +use Route; + class SampleServiceProvider extends ServiceProvider { @@ -42,7 +44,15 @@ class SampleServiceProvider extends ServiceProvider */ protected function registerRoutes() { - $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + Route::group([ + 'as' => 'sample.', + 'prefix' => 'sample', + // If you want a RESTful module, change this to 'api' + 'middleware' => ['web'], + 'namespace' => 'Modules\Sample\Http\Controllers' + ], function() { + $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + }); } /** diff --git a/resources/modules/stubs/routes.stub b/resources/modules/stubs/routes.stub index 79436f8f..352f275f 100644 --- a/resources/modules/stubs/routes.stub +++ b/resources/modules/stubs/routes.stub @@ -1,14 +1,8 @@ '$LOWER_NAME$.', - 'prefix' => '$LOWER_NAME$', - 'middleware' => [ - 'web', - 'role:admin|user' # leave blank for public - ], - 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers' -], function() { +Route::group(['middleware' => [ + 'role:admin|user' # leave blank to make this public +]], function() { # all your routes are prefixed with the above prefix # e.g. yoursite.com/sample diff --git a/resources/modules/stubs/scaffold/provider.stub b/resources/modules/stubs/scaffold/provider.stub index 77d64132..f3fda2c5 100644 --- a/resources/modules/stubs/scaffold/provider.stub +++ b/resources/modules/stubs/scaffold/provider.stub @@ -4,6 +4,8 @@ namespace $NAMESPACE$; use Illuminate\Support\ServiceProvider; use Illuminate\Database\Eloquent\Factory; +use Route; + class $CLASS$ extends ServiceProvider { @@ -42,7 +44,15 @@ class $CLASS$ extends ServiceProvider */ protected function registerRoutes() { - $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + Route::group([ + 'as' => '$LOWER_NAME$.', + 'prefix' => '$LOWER_NAME$', + // If you want a RESTful module, change this to 'api' + 'middleware' => ['web'], + 'namespace' => '$MODULE_NAMESPACE$\$STUDLY_NAME$\Http\Controllers' + ], function() { + $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php'); + }); } /**