<?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('album_login', 'Auth\LoginController@showAlbumLoginForm');

Route::get('dologin', 'Auth\LoginController@doLogin');
Route::get('logout', 'Auth\LoginController@logout');
Route::get('noauth', 'Auth\LoginController@noauth');
Route::get('changePassword', 'Auth\ResetPasswordController@showChangeForm')->name('password.reset');
Route::post('changePassword', 'Auth\ResetPasswordController@changePassword');


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('s1/order/export', 'S1\Order\InfoController@export');
    Route::get('list', 'Card\User\InfoController@lists');
    Route::get('userCreate', 'Card\User\InfoController@userCreate');
    Route::post('userStore', 'Card\User\InfoController@userStore');


    $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]);
            }
        }
    }
});

//    Route::post('Base/Attachment/upload', 'Base\AttachmentController@upload');
//    Route::post('Base/Attachment/webupload', 'Base\AttachmentController@webupload');
//    Route::get('Card/User/Info/index','Card\User\InfoController@index');
//    Route::get('Card/User/Info/create','Card\User\InfoController@create');
//    Route::post('Card/User/Info/create','Card\User\InfoController@create');
//    Route::get('Card/User/Info/update','Card\User\InfoController@update');
//    Route::post('Card/User/Info/update','Card\User\InfoController@update');
//    Route::get('Card/User/Info/destroy','Card\User\InfoController@destroy');
//
//    Route::get('Card/User/Honor/index','Card\User\HonorController@index');
//    Route::get('Card/User/Honor/create','Card\User\HonorController@create');
//    Route::post('Card/User/Honor/create','Card\User\HonorController@create');
//    Route::get('Card/User/Honor/update','Card\User\HonorController@update');
//    Route::post('Card/User/Honor/update','Card\User\HonorController@update');
//    Route::get('Card/User/Honor/destroy','Card\User\HonorController@destroy');
//
//    Route::get('Card/User/Progress/index','Card\User\ProgressController@index');
//    Route::get('Card/User/Progress/create','Card\User\ProgressController@create');
//    Route::post('Card/User/Progress/create','Card\User\ProgressController@create');
//    Route::get('Card/User/Progress/update','Card\User\ProgressController@update');
//    Route::post('Card/User/Progress/update','Card\User\ProgressController@update');
//    Route::get('Card/User/Progress/destroy','Card\User\ProgressController@destroy');
//
//    Route::get('Card/User/Project/index','Card\User\ProjectController@index');
//    Route::get('Card/User/Project/create','Card\User\ProjectController@create');
//    Route::post('Card/User/Project/create','Card\User\ProjectController@create');
//    Route::get('Card/User/Project/update','Card\User\ProjectController@update');
//    Route::post('Card/User/Project/update','Card\User\ProjectController@update');
//    Route::get('Card/User/Project/destroy','Card\User\ProjectController@destroy');
//
//    Route::get('Card/Banner/index','Card\BannerController@index');
//    Route::get('Card/Banner/create','Card\BannerController@create');
//    Route::post('Card/Banner/create','Card\BannerController@create');
//    Route::get('Card/Banner/update','Card\BannerController@update');
//    Route::post('Card/Banner/update','Card\BannerController@update');
//    Route::get('Card/Banner/destroy','Card\BannerController@destroy');
