//判断路由啦 //\Illuminate\Support\Facades\Cache::forget('config'); $admin_path = 'mywujieguanliht'; try { $admin_path = config_cache('config.admin_path'); if (!$admin_path) { $admin_path = 'mywujieguanliht'; } } catch (Exception $exception) { $admin_path = 'mywujieguanliht'; } Route::prefix($admin_path)->group(function ($route) { // $route->get('/', 'HomeController@index')->name('admin.home'); $route->get('/', 'LoginController@showLoginForm')->name('admin.login'); $route->post('login', 'LoginController@login')->name('admin.post.login'); $route->get('logout', 'LoginController@logout')->name('admin.logout'); $route->group(['middleware' => 'admins'], function ($route) { $route->group(['prefix' => 'home'], function ($route) { $route->get('/', 'HomeController@index')->name('admin.home'); $route->get('console', 'HomeController@console'); $route->get('show/{type}/{id}', 'HomeController@show'); $route->any('update/{method}', 'HomeController@update'); }); //统计 $route->get('statis/{type}/{method}', 'StatisController@index'); $route->get('api/{type}/{name}', 'ApiController@index'); $route->any('excel/{type}', 'ExcelController@index'); //网站配置 $route->group(['prefix' => 'website'], function ($route) { $route->get('/', 'WebSiteController@index'); $route->post('store', 'WebSiteController@store'); }); //只需要首页和获取信息 $only_index = [ 'OrderHandleApiController', 'LogController',//单资源 'OrderController',//单资源 'PayForController',//单资源, 'MerchantMoneyLogController', 'MerchantCommissionController', 'SystemCommissionController', 'CollectController', 'MerchantLogController', 'MerchantOrderController', ]; foreach ($only_index as $c) { //自动获取 $controller = str_replace('Controller', '', $c); $controller_path = strtolower($controller); $route->get($controller_path, $c . '@index'); $route->any($controller_path . '/api/json', ['uses' => $c . '@apiJson']); if (in_array($c, ['OrderController', 'PayForController'])) { $route->get($controller_path . '/show/{id}', ['uses' => $c . '@show']); } if (in_array($c, ['OrderHandleApiController'])) { //订单处理 $route->get($controller_path . '/handle/{order_id}/{type}', 'OrderHandleApiController@handle'); $route->post($controller_path . '/handle/post/{order_id}/{type}', 'OrderHandleApiController@handlePost'); } } //资源增删改查 $resource = [ 'AdminPermissionController', 'AdminRoleController', 'AdminController', 'BannerController', 'SmsController', 'BankController', 'NoticeArticleController', 'NavController', 'UserController', 'MerchantController', 'ArticleController', 'GoodsController', 'GatewayController', 'ZhanxinController', 'GatewayWindController', 'NoticeArticleController', 'DrawSetController', 'DrawMoneyController', 'SystemUpdateLogController', 'BankTransferController', ]; foreach ($resource as $c) { //自动获取 $controller = str_replace('Controller', '', $c); $controller_path = strtolower($controller); //$route->resource($controller_path, $c); if (in_array($c, ['MerchantController'])) { $route->post($controller_path . '/check/{id}', ['uses' => $c . '@checkHandle']); } $route->group(['prefix' => $controller_path ], function ($route) use ($c) { $route->get('/', $c . '@index'); $route->get('create', $c . '@create'); $route->get('show/{id}', $c . '@show'); $route->post('store', $c . '@store'); $route->get('{id}/edit/', $c . '@edit'); $route->put('{id}', $c . '@update'); }); //主持列表json //echo $c.'@json'.'
'; $route->any($controller_path . '/api/json', ['uses' => $c . '@apiJson']); } $route->get('article/content/{id}', ['uses' => 'ArticleController@content']); $route->get('gateway/statics', ['uses' => 'GatewayController@statics']); $route->any('gateway/statics_data', ['uses' => 'GatewayController@statics_data']); $route->put('article/content/post', ['uses' => 'ArticleController@contentPost']); $route->any('handle/{type}', ['uses' => 'HandleController@handle']); $route->any('upload/{type}', ['uses' => 'FileUploadController@handle']); $type_controller = [ 'CategoryController', ]; foreach ($type_controller as $c) { //自动获取 $controller = str_replace('Controller', '', $c); $controller_path = strtolower($controller); $route->group(['prefix' => $controller_path . '/{group_type}'], function ($route) use ($c) { $route->get('/', $c . '@index'); $route->get('create', $c . '@create'); $route->post('store', $c . '@store'); $route->get('{id}/edit/', $c . '@edit'); $route->put('{id}', $c . '@update'); $route->any('/api/json', ['uses' => $c . '@apiJson']); }); } }); });