<?php
use App\Http\Controllers\LoginController;
use App\Http\Middleware\AdminRedirect;
use App\Http\Middleware\AdminAuth;
use App\Http\Controllers\Admin\RegisterController;

use Illuminate\Support\Facades\Route;

/***********************************************
 ***************後台首頁  route *******************
 * url 前綴字 admin ,
 * route name 前綴字 admin 已設定
 ****************************************************/
Route::get('/phpinfo', function () {
    return phpinfo();
});
/** no middleware
 * ajxa 丟這
 */
Route::get('register', [RegisterController::class, 'index'])->name('register');
Route::post('register/create', [RegisterController::class, 'registerCreate'])->name('register.create');

/**
 * has middleware admin 需登入
 */
Route::
        namespace('App\Http\Controllers\Admin') // 設置命名空間
    ->middleware([AdminRedirect::class, AdminAuth::class])
    ->group(function () {
        Route::get('/', 'IndexController@index')->name('index');
        Route::get('profile', 'IndexController@profile')->name('profile');
        Route::get('page-profile', 'IndexController@pageProfile')->name('page.profile');

        Route::put('profile/update', 'IndexController@profileUpdate')->name('profile.update');
        Route::get('memberlist', 'MemberController@index')->name('memberlist');
        Route::get('logout', [LoginController::class, 'adminLogout'])->name(name: 'logout');

        Route::prefix('setting')->group(function () {
            Route::get('/', 'SettingController@index')->name('setting');
            Route::get('promocode', 'SettingController@promoCode')->name('setting.promocode');
            Route::get('promocode/used', 'SettingController@promoCode')->name('promocode.status');
            Route::post('promocode', 'SettingController@promoCodeCreate')->name('promocode.create');
            Route::get('adminlist', 'SettingController@adminIndex')->name('setting.adminlist');
            Route::patch('canlogin/status', 'SettingController@loginStatus')->name('canlogin.status');
        });
    });
// line 登入後查詢;
Route::get('login/line/callback', [LoginController::class, 'handleProviderCallback'])->name('login.line.callback');
Route::get('login', [LoginController::class, 'adminIndex'])->name('login');
Route::post('login/process', [LoginController::class, 'adminNormalLogin'])->name('login.post');
//後台 line 登入;
Route::get('login/line', [LoginController::class, 'redirectToProvider'])->name('login.line');
