admin.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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('test', 'TestController@index');
  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::get('changePassword', 'Auth\ResetPasswordController@showChangeForm')->name('password.reset');
  19. Route::post('changePassword', 'Auth\ResetPasswordController@changePassword');
  20. Route::group(['middleware' => ['auth.admin']], function() {
  21. $uri = request()->path();
  22. $uri = str_replace('admin/' ,'', $uri);
  23. $uri = str_replace('admin' ,'', $uri);
  24. if ($uri == '') {
  25. Route::any('/', ['as' => 'admin',
  26. 'uses' => 'Base\IndexController@index']);
  27. } else {
  28. $aUri = $baseUri = explode('/', $uri);
  29. if (count($aUri) > 1) {
  30. unset($aUri[count($aUri) - 1]);
  31. $file = app_path() . '/Http/Controllers/Admin/' . implode("/", $aUri) . "Controller.php";
  32. if (file_exists($file)) {
  33. $controller = implode("\\", $aUri) . "Controller";
  34. $action = $controller . "@" . $baseUri[count($aUri)];
  35. Route::any($uri, ['as' => 'admin',
  36. 'uses' => $action]);
  37. }
  38. }
  39. }
  40. });