<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/
//
//Route::get('/login', 'Admin\Foundation\LoginController@login');
Route::get('login', 'Auth\LoginController@showLoginForm')->name('admin.login');
Route::post('login','Auth\LoginController@login');
Route::get('logout', 'Auth\LoginController@logout');
Route::get('noauth', 'Auth\LoginController@noauth');


Route::group(['middleware' => ['auth.admin']], function() {
//参数设置
    Route::get('setting/banner/index', 'Settings\SettingsController@banner');
    Route::any('setting/banner/create', 'Settings\SettingsController@bannerCreate');
    Route::any('setting/banner/update', 'Settings\SettingsController@bannerUpdate');
    Route::get('setting/banner/destroy', 'Settings\SettingsController@bannerDestroy');
    Route::get('setting/banner/view', 'Settings\SettingsController@bannerView');
    Route::get('setting/sign/index', 'Settings\SettingsController@sign');
    Route::any('setting/sign/create', 'Settings\SettingsController@signCreate');
    Route::any('setting/sign/update', 'Settings\SettingsController@signUpdate');
    Route::get('setting/sign/destroy', 'Settings\SettingsController@signDestroy');
    Route::get('setting/sign/view', 'Settings\SettingsController@signView');
    Route::any('setting/paihang/edit', 'Settings\SettingsController@paihangEdit');
    Route::any('setting/score/edit', 'Settings\SettingsController@scoreEdit');

    $uri =  request()->path();
    $uri = str_replace('admin/' ,'', $uri);
    $uri = str_replace('admin' ,'', $uri);
    if ($uri == '') {
        Route::any('/', ['as' => 'admin',
            'uses' => 'Base\IndexController@index']);
    } else {
        $aUri = $baseUri = explode('/', $uri);
        if (count($aUri) > 1) {
            unset($aUri[count($aUri) - 1]);
            $file = app_path() . '/Http/Controllers/Admin/' . implode("/", $aUri) . "Controller.php";
            if (file_exists($file)) {
                $controller = implode("\\", $aUri) . "Controller";
                $action = $controller . "@" . $baseUri[count($aUri)];
                Route::any($uri, ['as' => 'admin',
                    'uses' => $action]);
            }
        }

    }

});