|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* ROUTER FOR API GENERATOR */ |
|
4
|
|
|
$namespace = '\crocodicstudio\crudbooster\controllers'; |
|
5
|
|
|
|
|
6
|
|
|
Route::group(['middleware' => ['api', '\crocodicstudio\crudbooster\middlewares\CBAuthAPI'], 'namespace' => 'App\Http\Controllers'], function () { |
|
7
|
|
|
//Router for custom api defeault |
|
8
|
|
|
|
|
9
|
|
|
$dir = scandir(base_path("app/Http/Controllers")); |
|
10
|
|
|
foreach ($dir as $v) { |
|
11
|
|
|
$v = str_replace('.php', '', $v); |
|
12
|
|
|
$names = array_filter(preg_split('/(?=[A-Z])/', str_replace('Controller', '', $v))); |
|
|
|
|
|
|
13
|
|
|
$names = strtolower(implode('_', $names)); |
|
14
|
|
|
|
|
15
|
|
|
if (substr($names, 0, 4) == 'api_') { |
|
16
|
|
|
$names = str_replace('api_', '', $names); |
|
17
|
|
|
Route::any('api/'.$names, $v.'@execute_api'); |
|
18
|
|
|
} |
|
19
|
|
|
} |
|
20
|
|
|
}); |
|
21
|
|
|
|
|
22
|
|
|
/* ROUTER FOR UPLOADS */ |
|
23
|
|
|
Route::group(['middleware' => ['web'], 'namespace' => $namespace], function () { |
|
24
|
|
|
Route::get('api-documentation', ['uses' => 'ApiCustomController@apiDocumentation', 'as' => 'apiDocumentation']); |
|
25
|
|
|
Route::get('download-documentation-postman', ['uses' => 'ApiCustomController@getDownloadPostman', 'as' => 'downloadDocumentationPostman']); |
|
26
|
|
|
Route::get('uploads/{one?}/{two?}/{three?}/{four?}/{five?}', ['uses' => 'FileController@getPreview', 'as' => 'fileControllerPreview']); |
|
27
|
|
|
}); |
|
28
|
|
|
|
|
29
|
|
|
/* ROUTER FOR WEB */ |
|
30
|
|
|
Route::group(['middleware' => ['web'], 'prefix' => config('crudbooster.ADMIN_PATH'), 'namespace' => $namespace], function () { |
|
31
|
|
|
|
|
32
|
|
|
Route::post('unlock-screen', ['uses' => 'AdminController@postUnlockScreen', 'as' => 'postUnlockScreen']); |
|
33
|
|
|
Route::get('lock-screen', ['uses' => 'AdminController@getLockscreen', 'as' => 'getLockScreen']); |
|
34
|
|
|
Route::post('forgot', ['uses' => 'AdminController@postForgot', 'as' => 'postForgot']); |
|
35
|
|
|
Route::get('forgot', ['uses' => 'AdminController@getForgot', 'as' => 'getForgot']); |
|
36
|
|
|
Route::post('register', ['uses' => 'AdminController@postRegister', 'as' => 'postRegister']); |
|
37
|
|
|
Route::get('register', ['uses' => 'AdminController@getRegister', 'as' => 'getRegister']); |
|
38
|
|
|
Route::get('logout', ['uses' => 'AdminController@getLogout', 'as' => 'getLogout']); |
|
39
|
|
|
Route::post('login', ['uses' => 'AdminController@postLogin', 'as' => 'postLogin']); |
|
40
|
|
|
Route::get('login', ['uses' => 'AdminController@getLogin', 'as' => 'getLogin']); |
|
41
|
|
|
}); |
|
42
|
|
|
|
|
43
|
|
|
// ROUTER FOR OWN CONTROLLER FROM CB |
|
44
|
|
|
Route::group([ |
|
45
|
|
|
'middleware' => ['web', '\crocodicstudio\crudbooster\middlewares\CBBackend'], |
|
46
|
|
|
'prefix' => config('crudbooster.ADMIN_PATH'), |
|
47
|
|
|
'namespace' => 'App\Http\Controllers', |
|
48
|
|
|
], function () use ($namespace) { |
|
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
Route::get('/',function () { |
|
51
|
|
|
}); |
|
52
|
|
|
try { |
|
53
|
|
|
$moduls = DB::table('cms_moduls')->where('path', '!=', '')->where('controller', '!=', '') |
|
54
|
|
|
->where('is_protected', 0)->where('deleted_at', null)->get(); |
|
55
|
|
|
foreach ($moduls as $v) { |
|
56
|
|
|
CRUDBooster::routeController($v->path, $v->controller); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
}); |
|
62
|
|
|
|
|
63
|
|
|
/* ROUTER FOR BACKEND CRUDBOOSTER */ |
|
64
|
|
|
Route::group([ |
|
65
|
|
|
'middleware' => ['web', '\crocodicstudio\crudbooster\middlewares\CBBackend'], |
|
66
|
|
|
'prefix' => config('crudbooster.ADMIN_PATH'), |
|
67
|
|
|
'namespace' => $namespace, |
|
68
|
|
|
], function () { |
|
69
|
|
|
|
|
70
|
|
|
/* DO NOT EDIT THESE BELLOW LINES */ |
|
71
|
|
|
if (Request::is(config('crudbooster.ADMIN_PATH'))) { |
|
72
|
|
|
$menus = DB::table('cms_menus')->where('is_dashboard', 1)->first(); |
|
73
|
|
|
if (! $menus) { |
|
74
|
|
|
CRUDBooster::routeController('/', 'AdminController', $namespace = '\crocodicstudio\crudbooster\controllers'); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
CRUDBooster::routeController('api_generator', 'ApiCustomController', $namespace = '\crocodicstudio\crudbooster\controllers'); |
|
79
|
|
|
|
|
80
|
|
|
try { |
|
81
|
|
|
|
|
82
|
|
|
$master_controller = glob(__DIR__.'/controllers/*.php'); |
|
83
|
|
|
foreach ($master_controller as &$m) { |
|
84
|
|
|
$m = str_replace('.php', '', basename($m)); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
$moduls = DB::table('cms_moduls')->whereIn('controller', $master_controller)->get(); |
|
88
|
|
|
|
|
89
|
|
|
foreach ($moduls as $v) { |
|
90
|
|
|
if (@$v->path && @$v->controller) { |
|
91
|
|
|
CRUDBooster::routeController($v->path, $v->controller, $namespace = '\crocodicstudio\crudbooster\controllers'); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
} catch (Exception $e) { |
|
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
}); |
|
98
|
|
|
|