<?php

use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\AdminDashboardController;
use App\Http\Controllers\Admin\AdminWebsiteManagementController;
use App\Http\Controllers\Admin\AdminUsersManagementController;
use App\Http\Controllers\Admin\AdminAmountManagementController;
use App\Http\Controllers\Admin\AdminBonusHistoryController;
use App\Http\Controllers\Admin\AdminCommissionHistoryController;
use App\Http\Controllers\Admin\AdminComplaintsController;
use App\Http\Controllers\Admin\AdminInterestHistoryController;
use App\Http\Controllers\Admin\AdminNextManagement;
use App\Http\Controllers\Admin\AdminRechargeManagementController;
use App\Http\Controllers\Admin\AdminRewardManagementController;
use App\Http\Controllers\Admin\AdminTradeHistoryController;
use App\Http\Controllers\Admin\AdminWinningManagement;
use App\Http\Controllers\Admin\AdminWithdrawalManagementController;
use App\Http\Controllers\AdminOrdersManagement;
use App\Http\Controllers\BankCardController;
use App\Http\Controllers\ComplaintsController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\GameController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\OtpController;
use App\Http\Controllers\TransactionController;
use App\Http\Controllers\UserPromotionController;
use App\Http\Controllers\WithdrawalController;
use App\Http\Controllers\Admin\AdminSliderManagementController;
use App\Http\Controllers\Admin\AdminUpiManagementController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AviatorController;


Route::get('/maintenance', function () {
    return view('maintenance');
});


Route::group(['middleware' => 'Maintenance'], function () {
    Route::get('/', [HomeController::class, 'Home']);
    Route::get('/search', [HomeController::class, 'Search']);
    Route::get('/download/apk', [HomeController::class, 'DownloadAPK']);
    Route::any('/search/product', [HomeController::class, 'SearchProduct']);
    Route::get('/product/{id}', [HomeController::class, 'ProductDetail']);

    Route::get('/login', [HomeController::class, 'Login'])->name('login');
    Route::post('/login', [HomeController::class, 'TryLogin']);
    Route::get('/forgotPassword', [HomeController::class, 'ForgotPassword']);
    Route::post('/forgotPassword', [HomeController::class, 'ForgotPasswordUpdate']);

    Route::get('/register', [HomeController::class, 'Register'])->name('register');
    Route::post('/register', [HomeController::class, 'NewRegistration']);
    Route::post('/number/search', [OtpController::class, 'SearchNumber']);
    Route::post('/number/confirm', [OtpController::class, 'ConfirmNumber']);
    Route::post('/check/otp', [OtpController::class, 'CheckOtp']);

    Route::group(['prefix' => 'user', 'middleware' => ['VerifyUser', 'can:user']], function () {
        Route::get('/get-aviator-url', [AviatorController::class, 'getGameToken'])->name('get.aviator.token');

        Route::get('/logout', [HomeController::class, 'Logout']);

        Route::get('/dashboard', [DashboardController::class, 'Dashboard']);
        Route::post('/envelope/verify', [DashboardController::class, 'VerifyEnvelope']);
        Route::get('/envelope/{code}', [DashboardController::class, 'Envelope']);

        Route::post('/signin', [DashboardController::class, 'signin']);

        Route::get('/recharge', [DashboardController::class, 'Recharge']);
        Route::get('/get-gateyway-url/{amount}', [TransactionController::class, 'RedirectUrl']);
        Route::get('/upi-money-upi-payment-url/{amount}', [TransactionController::class, 'RedirectUrlUPIMoney']);
        Route::get('/rechargeRecord', [DashboardController::class, 'RechargeRecord']);
        Route::post('/recharge', [DashboardController::class, 'RechargeNext']);
        Route::get('/checkout', [DashboardController::class, 'Checkout']);
        Route::post('/checkout', [DashboardController::class, 'ProcessCheckout']);
        Route::post('/verify/ref_no', [DashboardController::class, 'VerifyPaymentRefNo']);
        Route::get('/promotion', [UserPromotionController::class, 'Promotion']);

        Route::get('/bankCard', [BankCardController::class, 'BankCard']);
        Route::get('/addBankCard', [BankCardController::class, 'AddBankCard']);
        Route::post('/addBankCard', [BankCardController::class, 'SaveBankCard']);
        Route::get('/edit/bankCard/{id}', [BankCardController::class, 'EditBankCard']);
        Route::post('/update/bankCard', [BankCardController::class, 'UpdateBankCard']);
        Route::get('/delete/bankCard/{id}', [BankCardController::class, 'DeleteBankCard']);
        Route::post('/bank/mobile/search', [BankCardController::class, 'BankMobileSearch']);
        Route::post('/check/bank/account/otp', [BankCardController::class, 'CheckBankAccountOtp']);

        Route::get('/resetPassword', [HomeController::class, 'ResetPassword']);
        Route::post('/resetPassword/otp', [OtpController::class, 'ResetPasswordOtp']);
        Route::post('/check/resetPassword/otp', [OtpController::class, 'CheckResetPasswordOtp']);
        Route::post('/resetPassword', [HomeController::class, 'ProcessResetPassword']);

        Route::get('/address', [HomeController::class, 'Address']);
        Route::post('/address', [HomeController::class, 'SaveAddress']);

        Route::get('/withdrawal', [WithdrawalController::class, 'Withdrawal']);
        Route::post('/withdrawal', [WithdrawalController::class, 'SubmitWithdrawRequest']);
        Route::get('/withdrawalRecord', [WithdrawalController::class, 'WithdrawalRecord']);

        Route::get('/complaints', [ComplaintsController::class, 'Complaints']);
        Route::get('/addComplaint', [ComplaintsController::class, 'AddComplaint']);
        Route::post('/addComplaint', [ComplaintsController::class, 'SubmitComplaint']);
        Route::get('/complaintsRecord', [ComplaintsController::class, 'WithdrawalRecord']);

        Route::post('/getTime', [GameController::class, 'GetGamesTime']);

        // Route::get('/gameDashboard', [GameController::class, 'GameDashboard']);
        Route::get('/gameDashboard/{id?}', [GameController::class, 'GameDashboardWithType']);
        //   api route to get user result data
        Route::get('/win/getUserResultData/{id}', [GameController::class, 'GetUserResultData']);

        Route::post('/save/bet', [GameController::class, 'SaveBet']);
        Route::post('/gameRecord/all', [GameController::class, 'GameRecords']);
        Route::post('/gameRecord/mine', [GameController::class, 'MyGameRecords']);

        Route::get('/trend/{id}', [GameController::class, 'Trend']);
        Route::post('/trend/records', [GameController::class, 'TrendRecords']);


        Route::get('/transactions', [TransactionController::class, 'Transactions']);

        Route::get('/orders', [OrderController::class, 'Orders']);
        Route::post('/create/order', [OrderController::class, 'CreateOrder']);

        Route::get('/privacyPolicy', [DashboardController::class, 'PrivacyPolicy']);
        Route::get('/riskAgreement', [DashboardController::class, 'RiskAgreement']);
        Route::get('/redEnvelope', [DashboardController::class, 'RedEnvelope']);
        Route::get('/addRedEnvelope', [DashboardController::class, 'AddRedEnvelope']);
    });
});

Route::get('/admin/login', [AdminController::class, 'AdminLogin'])->name('AdminLogin');
Route::post('/admin/login', [AdminController::class, 'CheckAdminLogin']);

Route::group(['prefix' => 'admin', 'middleware' => ['VerifyAdmin', 'can:admin']], function () {
    Route::get('/logout', [AdminController::class, 'Logout']);

    Route::get('/', [AdminDashboardController::class, 'Dashboard']);
    Route::get('/dashboard', [AdminDashboardController::class, 'Dashboard']);

    Route::get('/slider-management', [AdminSliderManagementController::class, 'SliderManagement']);
    Route::post('/slider-management', [AdminSliderManagementController::class, 'AddSliderManagement']);
    Route::get('/slider-management/delete/{id}', [AdminSliderManagementController::class, 'DeleteSlider']);

    Route::get('/website-management', [AdminWebsiteManagementController::class, 'WebsiteManagement']);
    Route::post('/website-management', [AdminWebsiteManagementController::class, 'UpdateWebsiteManagement']);

    Route::get('/users-management', [AdminUsersManagementController::class, 'UsersManagement']);
    Route::any('/users-management/search', [AdminUsersManagementController::class, 'SearchUsersManagement']);
    Route::get('/user/active/{id}', [AdminUsersManagementController::class, 'ActiveUser']);
    Route::get('/user/inactive/{id}', [AdminUsersManagementController::class, 'InactiveUser']);
    Route::get('/user/delete/{id}', [AdminUsersManagementController::class, 'DeleteUser']);

    Route::get('/amount-management', [AdminAmountManagementController::class, 'AmountManagement']);
    Route::post('/amount-management', [AdminAmountManagementController::class, 'UpdateAmountManagement']);

    Route::get('/upi-management', [AdminUpiManagementController::class, 'UpiManagement']);
    Route::post('/upis/add', [AdminUpiManagementController::class, 'AddUpi']);
    Route::get('/upis/delete/{id}', [AdminUpiManagementController::class, 'DeleteUpi']);
    Route::get('/recharge-management', [AdminRechargeManagementController::class, 'RechargeManagement']);
    Route::get('/recharge/approve/{id}', [AdminRechargeManagementController::class, 'ApproveRecharge']);
    Route::post('/recharge/disapprove', [AdminRechargeManagementController::class, 'DisapproveRecharge']);
    Route::get('/recharge/delete/{id}', [AdminRechargeManagementController::class, 'DeleteRecharge']);
    Route::any('/recharge-history/search', [AdminRechargeManagementController::class, 'RechargeHistory']);


    Route::get('/withdrawal-management', [AdminWithdrawalManagementController::class, 'WithdrawalManagement']);
    Route::post('/withdrawal/info', [AdminWithdrawalManagementController::class, 'WithdrawalInfo']);
    Route::get('/withdrawal/agree/{id}', [AdminWithdrawalManagementController::class, 'AgreeWithdrawal']);
    Route::get('/withdrawal/approve/{id}', [AdminWithdrawalManagementController::class, 'ApproveWithdrawal']);
    Route::get('/withdrawal/accept-api/{id}', [AdminWithdrawalManagementController::class, 'ApproveWithdrawalApi']);

    Route::post('/withdrawal/disapprove', [AdminWithdrawalManagementController::class, 'DisapproveWithdrawal']);
    Route::get('/withdrawal/delete/{id}', [AdminWithdrawalManagementController::class, 'DeleteWithdrawal']);
    Route::any('/withdrawal-history/search', [AdminWithdrawalManagementController::class, 'WithdrawalHistory']);

    Route::get('/complaints-management', [AdminComplaintsController::class, 'ComplaintsManagement']);
    Route::post('/complaint/reply', [AdminComplaintsController::class, 'ComplaintReply']);
    Route::get('/complaint/delete/{id}', [AdminComplaintsController::class, 'DeleteComplaint']);

    Route::get('/winning-management/{id?}', [AdminWinningManagement::class, 'WinningManagement']);

    Route::get('/next-management', [AdminNextManagement::class, 'NextManagement']);
    Route::post('/next-management/records', [AdminNextManagement::class, 'NextManagementRecords']);
    Route::post('/gameId/setResult', [AdminNextManagement::class, 'SetGameIdResult']);

    Route::post('/betting/records', [AdminWinningManagement::class, 'BettingRecords']);
    Route::post('/set/gameSettings', [AdminWinningManagement::class, 'SetGameSettings']);

    Route::get('/orders-management', [AdminOrdersManagement::class, 'OrdersManagement']);
    Route::post('/order/info', [AdminOrdersManagement::class, 'OrderInfo']);
    Route::post('/order/update', [AdminOrdersManagement::class, 'UpdateOrder']);
    Route::get('/order/delete/{id}', [AdminOrdersManagement::class, 'DeleteOrder']);

    Route::get('/rewards-management', [AdminRewardManagementController::class, 'RewardManagement']);
    Route::post('/reward/save', [AdminRewardManagementController::class, 'SaveReward']);

    Route::get('/red-envelope', [AdminRewardManagementController::class, 'RedEnvelope']);
    Route::get('/red-envelope/active/{id}', [AdminRewardManagementController::class, 'RedEnvelopeActive']);
    Route::get('/red-envelope/inactive/{id}', [AdminRewardManagementController::class, 'RedEnvelopeInactive']);
    Route::post('/red-envelope/save', [AdminRewardManagementController::class, 'SaveRedEnvelope']);

    Route::get('/trade-history', [AdminTradeHistoryController::class, 'TradeHistory']);
    Route::any('/trade-history/search', [AdminTradeHistoryController::class, 'TradeHistorySearch']);

    Route::get('/bonus-history', [AdminBonusHistoryController::class, 'BonusHistory']);
    Route::any('/bonus-history/search', [AdminBonusHistoryController::class, 'BonusHistorySearch']);

    Route::get('/commission-history', [AdminCommissionHistoryController::class, 'CommissionHistory']);
    Route::any('/commission-history/search', [AdminCommissionHistoryController::class, 'CommissionHistorySearch']);

    Route::get('/interest-history', [AdminInterestHistoryController::class, 'InterestHistory']);
    Route::any('/interest-history/search', [AdminInterestHistoryController::class, 'InterestHistorySearch']);

    Route::get('/change/password', [AdminController::class, 'ChangePassword']);
    Route::post('/change/password', [AdminController::class, 'SaveChangepassword']);
});
