2017-12-14 12:24:41 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace $NAMESPACE$;
|
|
|
|
|
|
|
|
use Illuminate\Routing\Router;
|
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
2020-09-21 07:10:52 +08:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2017-12-14 12:24:41 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
2020-09-21 07:10:52 +08:00
|
|
|
* Register the routes required for your module here
|
2018-03-20 09:50:40 +08:00
|
|
|
*/
|
2020-09-21 07:10:52 +08:00
|
|
|
class RouteServiceProvider extends ServiceProvider
|
2017-12-14 12:24:41 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The root namespace to assume when generating URLs to actions.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2020-09-21 07:10:52 +08:00
|
|
|
protected $namespace = '$MODULE_NAMESPACE$\$MODULE$\$CONTROLLER_NAMESPACE$';
|
2017-12-14 12:24:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called before routes are registered.
|
|
|
|
*
|
|
|
|
* Register any model bindings or pattern based filters.
|
|
|
|
*
|
|
|
|
* @param Router $router
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function before(Router $router)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the routes for the application.
|
|
|
|
*
|
2020-09-21 07:10:52 +08:00
|
|
|
* @param \Illuminate\Routing\Router $router
|
|
|
|
*
|
2017-12-14 12:24:41 +08:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function map(Router $router)
|
|
|
|
{
|
2020-09-21 07:10:52 +08:00
|
|
|
$this->registerWebRoutes();
|
|
|
|
$this->registerAdminRoutes();
|
|
|
|
$this->registerApiRoutes();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected function registerWebRoutes(): void
|
|
|
|
{
|
|
|
|
$config = [
|
|
|
|
'as' => '$LOWER_NAME$.',
|
|
|
|
'prefix' => '$LOWER_NAME$',
|
|
|
|
'namespace' => $this->namespace.'\Frontend',
|
|
|
|
'middleware' => ['web'],
|
|
|
|
];
|
|
|
|
|
|
|
|
Route::group($config, function() {
|
|
|
|
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function registerAdminRoutes(): void
|
|
|
|
{
|
|
|
|
$config = [
|
|
|
|
'as' => 'admin.$LOWER_NAME$.',
|
|
|
|
'prefix' => 'admin/$LOWER_NAME$',
|
|
|
|
'namespace' => $this->namespace.'\Admin',
|
|
|
|
'middleware' => ['web', 'role:admin'],
|
|
|
|
];
|
|
|
|
|
|
|
|
Route::group($config, function() {
|
|
|
|
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any API routes your module has. Remove this if you aren't using any
|
|
|
|
*/
|
|
|
|
protected function registerApiRoutes(): void
|
|
|
|
{
|
|
|
|
$config = [
|
|
|
|
'as' => 'admin.$LOWER_NAME$.',
|
|
|
|
'prefix' => 'admin/$LOWER_NAME$',
|
|
|
|
'namespace' => $this->namespace.'\Api',
|
|
|
|
'middleware' => ['api'],
|
|
|
|
];
|
|
|
|
|
|
|
|
Route::group($config, function() {
|
|
|
|
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/api.php');
|
|
|
|
});
|
2017-12-14 12:24:41 +08:00
|
|
|
}
|
|
|
|
}
|