Skip to content

Commit

Permalink
move menu routes to menuModule
Browse files Browse the repository at this point in the history
  • Loading branch information
imanghafoori1 committed Nov 9, 2017
1 parent 8830873 commit 1cbe647
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
28 changes: 28 additions & 0 deletions src/Modules/MenuModule/menus_routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,31 @@
Route::post('menus/upload-file', ['uses' => 'AdminMenusController@postUploadFile', 'as' => 'AdminMenusControllerPostUploadFile',]);
});

// ROUTER FOR OWN CONTROLLER FROM CB
Route::group([
'middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBBackend::class],
'prefix' => cbAdminPath(),
'namespace' => ctrlNamespace(),
], function () {
if (!Request::is(cbAdminPath())) {
return ;
}
$menus = DB::table('cms_menus')->where('is_dashboard', 1)->first();
if (!$menus) {
return ;
}
if ($menus->type == 'Statistic') {
Route::get('/', '\\crocodicstudio\\crudbooster\\StatisticModule\\AdminStatisticBuilderController@getDashboard');
} elseif ($menus->type == 'Module') {
$module = CRUDBooster::first('cms_moduls', ['path' => $menus->path]);
Route::get('/', $module->controller.'@getIndex');
} elseif ($menus->type == 'Route') {
$action = str_replace("Controller", "Controller@", $menus->path);
$action = str_replace(['Get', 'Post'], ['get', 'post'], $action);
Route::get('/', $action);
} elseif ($menus->type == 'Controller & Method') {
Route::get('/', $menus->path);
} elseif ($menus->type == 'URL') {
redirect($menus->path);
}
});
22 changes: 0 additions & 22 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,6 @@
'prefix' => cbAdminPath(),
'namespace' => ctrlNamespace(),
], function () {

if (Request::is(cbAdminPath())) {
$menus = DB::table('cms_menus')->where('is_dashboard', 1)->first();
if ($menus) {
if ($menus->type == 'Statistic') {
Route::get('/', '\\crocodicstudio\\crudbooster\\StatisticModule\\AdminStatisticBuilderController@getDashboard');
} elseif ($menus->type == 'Module') {
$module = CRUDBooster::first('cms_moduls', ['path' => $menus->path]);
Route::get('/', $module->controller.'@getIndex');
} elseif ($menus->type == 'Route') {
$action = str_replace("Controller", "Controller@", $menus->path);
$action = str_replace(['Get', 'Post'], ['get', 'post'], $action);
Route::get('/', $action);
} elseif ($menus->type == 'Controller & Method') {
Route::get('/', $menus->path);
} elseif ($menus->type == 'URL') {
redirect($menus->path);
}
}
}

try {
$moduls = DB::table('cms_moduls')->where('path', '!=', '')->where('controller', '!=', '')->where('is_protected', 0)->get();
foreach ($moduls as $v) {
Expand Down Expand Up @@ -85,7 +64,6 @@
'prefix' => cbAdminPath(),
'namespace' => $namespace,
], function () use ($namespace) {
//CRUDBooster::routeController('file-manager', 'AdminFileManagerController', $namespace);
CRUDBooster::routeController('email-templates', 'AdminEmailTemplatesController', $namespace);
CRUDBooster::routeController('logs', 'AdminLogsController', $namespace);
});
Expand Down

0 comments on commit 1cbe647

Please sign in to comment.