<?php
namespace QxCMS\Modules;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
class ApiServiceProvider extends ServiceProvider
{
protected $namespace = 'QxCMS\Modules';
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot(Router $router)
{
$modules = config('modules.modules');
array_filter($modules, function($module) use ($router) {
if(strtolower($module)=='api')
{
$this->registerModuleRoute($router, $module);
}
});
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/tables.php', 'tables'
);
}
public function registerModuleRoute($router, $module)
{
$router->group([
'namespace' => $this->namespace.'\\'.$module.'\\'.'Controllers',
'middleware' => 'cors',
'prefix' => strtolower($module)
], function ($router) use ($module) {
require __DIR__."/$module/routes.php";
});
}
}