admin.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Web Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | This file is where you may define all of the routes that are handled
  8. | by your application. Just tell Laravel the URIs it should respond
  9. | to using a Closure or controller method. Build something great!
  10. |
  11. */
  12. //
  13. //Route::get('/login', 'Admin\Foundation\LoginController@login');
  14. Route::get('login', 'Auth\LoginController@showLoginForm')->name('admin.login');
  15. Route::post('login','Auth\LoginController@login');
  16. Route::get('logout', 'Auth\LoginController@logout');
  17. Route::get('noauth', 'Auth\LoginController@noauth');
  18. Route::group(['middleware' => ['auth.admin']], function() {
  19. //参数设置
  20. Route::get('setting/banner/index', 'Settings\SettingsController@banner');
  21. Route::get('setting/banner/create', 'Settings\SettingsController@bannerCreate');
  22. Route::get('setting/banner/update', 'Settings\SettingsController@bannerUpdate');
  23. Route::get('setting/banner/destroy', 'Settings\SettingsController@bannerDestroy');
  24. Route::get('setting/banner/view', 'Settings\SettingsController@bannerView');
  25. $uri = request()->path();
  26. $uri = str_replace('admin/' ,'', $uri);
  27. $uri = str_replace('admin' ,'', $uri);
  28. if ($uri == '') {
  29. Route::any('/', ['as' => 'admin',
  30. 'uses' => 'Base\IndexController@index']);
  31. } else {
  32. $aUri = $baseUri = explode('/', $uri);
  33. if (count($aUri) > 1) {
  34. unset($aUri[count($aUri) - 1]);
  35. $file = app_path() . '/Http/Controllers/Admin/' . implode("/", $aUri) . "Controller.php";
  36. if (file_exists($file)) {
  37. $controller = implode("\\", $aUri) . "Controller";
  38. $action = $controller . "@" . $baseUri[count($aUri)];
  39. Route::any($uri, ['as' => 'admin',
  40. 'uses' => $action]);
  41. }
  42. }
  43. }
  44. });