<?php

use App\Models\UserNotification;
use App\Models\AdminNotification;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\ImageController;
use App\Models\Deposit;
use App\Models\Order;
use App\Models\User;
use App\Models\UserBalanceLog;
use App\Models\UserLoginLog;
use Illuminate\Http\Request;
use Jenssegers\Agent\Agent;

/* Admin Menu Routes */
Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware' => ['auth:admin', 'admin_cookie']], function() {
    Route::get('/', [\App\Http\Controllers\Admin\AuthController::class, 'home']);
    Route::group(['prefix' => 'sample/tracking-log'], function() {
        Route::get('list', [\App\Http\Controllers\Sample\TrackingLogController::class, 'list']);
    });
    Route::group(['prefix' => 'auth'], function() {
        Route::get('login', [\App\Http\Controllers\Admin\AuthController::class, 'getLogin'])->withoutMiddleware(['auth:admin', 'status'])->name('admin.login');
        Route::post('login', [\App\Http\Controllers\Admin\AuthController::class, 'postLogin'])->withoutMiddleware(['auth:admin', 'status'])->name('admin.login');
        Route::get('logout', [\App\Http\Controllers\Admin\AuthController::class, 'logout'])->withoutMiddleware(['auth:admin', 'status']);
    });
    Route::group(['prefix' => 'admin'], function() {
        Route::get('list', [\App\Http\Controllers\Admin\AdminController::class, 'list']);
        Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\AdminController::class, 'getForm']);
        Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\AdminController::class, 'postForm']);
        Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\AdminController::class, 'delete']);
        Route::get('status/{target:id}/{status:status}', [\App\Http\Controllers\Admin\AdminController::class, 'status']);
    });
    Route::group(['prefix' => 'user'], function() {
        Route::get('list', [\App\Http\Controllers\Admin\UserController::class, 'list']);
        Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\UserController::class, 'getForm']);
        Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\UserController::class, 'postForm']);
        Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\UserController::class, 'detail']);
        Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\UserController::class, 'delete']);
        Route::get('status/{target:id}/{status:status}', [\App\Http\Controllers\Admin\UserController::class, 'status']);
        Route::get('verified/{target:id}/{status:status}', [\App\Http\Controllers\Admin\UserController::class, 'verified']);
    });
    Route::group(['prefix' => 'page'], function() {
        Route::get('notification', [\App\Http\Controllers\Admin\Page\PageController::class, 'notification']);
        Route::get('hof', [\App\Http\Controllers\Admin\Page\PageController::class, 'hof']);
        Route::group(['prefix' => 'ovo'], function() {
            Route::get('login', [\App\Http\Controllers\Admin\Page\OVOController::class, 'getLogin']);
            Route::post('login', [\App\Http\Controllers\Admin\Page\OVOController::class, 'postLogin']);
            Route::get('confirm', [\App\Http\Controllers\Admin\Page\OVOController::class, 'getConfirm']);
            Route::post('confirm', [\App\Http\Controllers\Admin\Page\OVOController::class, 'postConfirm']);
            Route::get('pin', [\App\Http\Controllers\Admin\Page\OVOController::class, 'getPin']);
            Route::post('pin', [\App\Http\Controllers\Admin\Page\OVOController::class, 'postPin']);
        });
        Route::group(['prefix' => 'gopay'], function() {
            Route::get('login', [\App\Http\Controllers\Admin\Page\GOPAYController::class, 'getLogin']);
            Route::post('login', [\App\Http\Controllers\Admin\Page\GOPAYController::class, 'postLogin']);
            Route::get('confirm', [\App\Http\Controllers\Admin\Page\GOPAYController::class, 'getConfirm']);
            Route::post('confirm', [\App\Http\Controllers\Admin\Page\GOPAYController::class, 'postConfirm']);
        });
    });
    
    Route::group(['prefix' => 'service'], function() {
        Route::get('list', [\App\Http\Controllers\Admin\Service\ServiceController::class, 'list']);
        Route::get('bulk/form/{target:id?}', [\App\Http\Controllers\Admin\Service\BulkController::class, 'getForm']);
        Route::post('bulk/form/{target:id?}', [\App\Http\Controllers\Admin\Service\BulkController::class, 'postForm']);
        Route::get('get/form/{target:id?}', [\App\Http\Controllers\Admin\Service\GetController::class, 'getForm']);
        Route::post('get/form/{target:id?}', [\App\Http\Controllers\Admin\Service\GetController::class, 'postForm']);
        Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Service\ServiceController::class, 'getForm']);
        Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Service\ServiceController::class, 'postForm']);
        Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\Service\ServiceController::class, 'detail']);
        Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Service\ServiceController::class, 'delete']);
        Route::get('status/{target:id}/{status:status}', [\App\Http\Controllers\Admin\Service\ServiceController::class, 'status']);
        Route::group(['prefix' => 'provider'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Service\ProviderController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Service\ProviderController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Service\ProviderController::class, 'postForm']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Service\ProviderController::class, 'delete']);
            Route::get('check/balance/{target:id}', [\App\Http\Controllers\Admin\Service\ProviderController::class, 'checkBalance']);
            Route::get('status/{target:id}/{status:status}', [\App\Http\Controllers\Admin\Service\ProviderController::class, 'status']);
        });
        Route::group(['prefix' => 'category'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Service\CategoryController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Service\CategoryController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Service\CategoryController::class, 'postForm']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Service\CategoryController::class, 'delete']);
            Route::get('status/{target:id}/{status:status}', [\App\Http\Controllers\Admin\Service\CategoryController::class, 'status']);
        });
        
        Route::group(['prefix' => 'custom_price'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Service\CustomPriceController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Service\CustomPriceController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Service\CustomPriceController::class, 'postForm']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Service\CustomPriceController::class, 'delete']);
        });
        Route::group(['prefix' => 'log'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Service\LogController::class, 'list']);
            Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\Service\LogController::class, 'detail']);
        });
    });
    Route::group(['prefix' => 'order'], function() {
        Route::get('list', [\App\Http\Controllers\Admin\OrderController::class, 'list']);
        Route::post('update', [\App\Http\Controllers\Admin\OrderController::class, 'update']);
        Route::get('form/{target:id}', [\App\Http\Controllers\Admin\OrderController::class, 'getForm']);
        Route::post('form/{target:id}', [\App\Http\Controllers\Admin\OrderController::class, 'postForm']);
        Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\OrderController::class, 'detail']);
        Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\OrderController::class, 'delete']);
        Route::get('report/list', [\App\Http\Controllers\Admin\OrderController::class, 'reportList']);
        Route::get('report', [\App\Http\Controllers\Admin\OrderController::class, 'report']);
        Route::group(['prefix' => 'refill'], function() {
            Route::get('create/{target:id}', [\App\Http\Controllers\Admin\OrderRefillController::class, 'create']);
            Route::get('list', [\App\Http\Controllers\Admin\OrderRefillController::class, 'list']);
            Route::get('form/{target:id}', [\App\Http\Controllers\Admin\OrderRefillController::class, 'getForm']);
            Route::post('form/{target:id}', [\App\Http\Controllers\Admin\OrderRefillController::class, 'postForm']);
            Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\OrderRefillController::class, 'detail']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\OrderRefillController::class, 'delete']);
        });
        Route::get('export-data', [\App\Http\Controllers\Admin\OrderController::class, 'export']);
    });
    Route::group(['prefix' => 'deposit'], function() {
        Route::get('list', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'list']);
        Route::get('confirm/{target:id}', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'confirm']);
        Route::get('cancel/{target:id}', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'cancel']);
        Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'detail']);
        Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'delete']);
        Route::get('report/list', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'reportList']);
        Route::get('report', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'report']);
        Route::group(['prefix' => 'send'], function() {
            Route::get('/', [\App\Http\Controllers\Admin\Deposit\SendController::class, 'getForm']);
            Route::post('/', [\App\Http\Controllers\Admin\Deposit\SendController::class, 'postForm']);
        });
        Route::group(['prefix' => 'method'], function() {
            Route::get('/list', [\App\Http\Controllers\Admin\Deposit\MethodController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Deposit\MethodController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Deposit\MethodController::class, 'postForm']);
            Route::get('detail/{target:id}', [\App\Http\Controllers\Admin\Deposit\MethodController::class, 'detail']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Deposit\MethodController::class, 'delete']);
            Route::get('status/{target:id}/{status:status}', [\App\Http\Controllers\Admin\Deposit\MethodController::class, 'status']);
        });
        Route::get('export-data', [\App\Http\Controllers\Admin\Deposit\DepositController::class, 'export']);
    });
    Route::group(['prefix' => 'ticket'], function() {
        Route::get('send', [\App\Http\Controllers\Admin\TicketController::class, 'getSend']);
        Route::post('send', [\App\Http\Controllers\Admin\TicketController::class, 'postSend']);
        Route::get('reply/{target:id}', [\App\Http\Controllers\Admin\TicketController::class, 'getReply']);
        Route::patch('reply/{target:id}', [\App\Http\Controllers\Admin\TicketController::class, 'postReply']);
        Route::get('list', [\App\Http\Controllers\Admin\TicketController::class, 'list']);
        Route::get('close/{target:id}', [\App\Http\Controllers\Admin\TicketController::class, 'close']);
        Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\TicketController::class, 'delete']);
    });
    Route::group(['prefix' => 'log'], function() {
        Route::get('user_register', [\App\Http\Controllers\Admin\LogController::class, 'user_register']);
        Route::get('user_login', [\App\Http\Controllers\Admin\LogController::class, 'user_login']);
        Route::get('admin_login', [\App\Http\Controllers\Admin\LogController::class, 'admin_login']);
        Route::get('user_balance', [\App\Http\Controllers\Admin\LogController::class, 'user_balance']);
        Route::get('user_balance/report', [\App\Http\Controllers\Admin\LogController::class, 'user_balance_report']);
        Route::get('bank_mutation', [\App\Http\Controllers\Admin\LogController::class, 'bank_mutation']);
    });
    Route::group(['prefix' => 'settings'], function() {
        Route::group(['prefix' => 'bank_account'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Settings\BankAccountController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Settings\BankAccountController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Settings\BankAccountController::class, 'postForm']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Settings\BankAccountController::class, 'delete']);
        });
        Route::group(['prefix' => 'website_information'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Settings\WebsiteInformationController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Settings\WebsiteInformationController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Settings\WebsiteInformationController::class, 'postForm']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Settings\WebsiteInformationController::class, 'delete']);
        });
        Route::group(['prefix' => 'website_page'], function() {
            Route::get('list', [\App\Http\Controllers\Admin\Settings\WebsitePageController::class, 'list']);
            Route::get('form/{target:id?}', [\App\Http\Controllers\Admin\Settings\WebsitePageController::class, 'getForm']);
            Route::post('form/{target:id?}', [\App\Http\Controllers\Admin\Settings\WebsitePageController::class, 'postForm']);
            Route::get('delete/{target:id}', [\App\Http\Controllers\Admin\Settings\WebsitePageController::class, 'delete']);
        });
        Route::group(['prefix' => 'website_configs'], function() {
            Route::get('/', [\App\Http\Controllers\Admin\Settings\WebsiteConfigController::class, 'getIndex']);
            Route::patch('/', [\App\Http\Controllers\Admin\Settings\WebsiteConfigController::class, 'postIndex']);
            Route::get('delete_logo/{target:id?}', [\App\Http\Controllers\Admin\Settings\WebsiteConfigController::class, 'delete_logo']);
            Route::get('delete_favicon', [\App\Http\Controllers\Admin\Settings\WebsiteConfigController::class, 'delete_favicon']);
            Route::get('test_email', [\App\Http\Controllers\Admin\Settings\WebsiteConfigController::class, 'test_email']);
        });
    });
});
/* Admin Menu Routes */
