<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Http\Request;

Route::get('/clear', function () {
    Artisan::call('optimize:clear');

    $output = Artisan::output();

    return response()->json([
        'status' => 'success',
        'message' => 'Application cache cleared successfully.',
        'output' => $output,
    ]);
});

Route::get('/ip', function (Request $request) {
    return response()->json([
        'ip' => $request->ip()
    ]);
});
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
*/
Route::get('/', function () {
    return redirect('/merchant/');
});

Route::namespace('File')->group(function () {
Route::get('/api-documentation', 'GatewaySettings@apiDoc')->name('api-documentation');
        });
Route::namespace('File')->prefix('/merchant')->group(function () {
    
Route::name('login.')->middleware(['throttle:10,1'])->group(function(){
    Route::get('/', 'LoginController@showLoginForm')->name('login');
    Route::post('/', 'LoginController@login')->name('login.auth');
    Route::get('/adminAuth/{id}', 'LoginController@adminLogin')->name('login.adminAuth');
    Route::get('/logout', 'LoginController@logout')->name('login.logout');
    Route::get('/register', 'LoginController@getRegister')->name('login.register');
    Route::post('/createAccount', 'LoginController@createAccount')->name('login.createAccount');
});


    Route::middleware(['auth', 'user'])->group(function () {

       Route::name('index.')->prefix('index')->group(function(){
        Route::get('/', 'DashboardController@dashboardAPI')->name('index.dashboard');  
        Route::get('/dashboard-data', 'DashboardController@getDashboardData')->name('index.dashboard-data'); 
        Route::get('/balance', 'DashboardController@getBalance')->name('index.balance'); 
        });
        
        Route::get('/push/{type}/{id}', 'DashboardController@pushCallback')->name('data.push');
        
        Route::get('/generate', 'GatewaySettings@makeApiKey')->name('generate.key');  
        Route::post('/password-update', 'GatewaySettings@submitPassword')->name('password.update');  
        Route::post('/profile-update', 'GatewaySettings@submitProfile')->name('profile.update');
        Route::get('/twofactor', 'GatewaySettings@show2faForm')->name('twofactor.twofactor'); 
        Route::post('/twofactor/enable', 'GatewaySettings@create2fa')->name('twofactor.enable');
        Route::post('/twofactor/disable', 'GatewaySettings@disable2fa')->name('twofactor.disable');
       // Route::post('/verify-g2fa', 'GatewaySettings@g2faVerification')->name('twofactor.verify');
        
        Route::name('deposit.')->group(function(){
        Route::get('/history', 'CollectionBDController@getMerchant')->name('deposit.history');
        });

        Route::name('payout.')->group(function(){
        Route::get('/payout', 'PayoutBDController@getPayout')->name('payout.payout');
        Route::get('/upload', 'PayoutBDController@getPayoutUpload')->name('payout.upload');
        Route::post('/bulkupload', 'PayoutBDController@Upload')->name('payout.bulkupload');
        Route::get('/getDownload/{id}', 'PayoutBDController@getDownload')->name('payout.data-download');
        Route::post('/payout/cancel/{id}','PayoutBDController@cancel')->name('payout.cancel');
        Route::post('/payout/faster/{id}', 'PayoutBDController@faster')->name('payout.faster');
        });
        
        Route::name('withdraws.')->group(function(){
        Route::get('/transactions', 'PayoutBDController@getSettle')->name('withdraws.transactions'); 
        Route::get('/method', 'PayoutBDController@getNewSettle')->name('withdraws.method'); 
        Route::post('/money', 'PayoutBDController@pushSettle')->name('withdraws.money'); 
        Route::get('/autoMethod', 'PayoutBDController@getAutoSettle')->name('withdraws.autoMethod');
        Route::post('/moneyApply', 'PayoutBDController@pushApply')->name('withdraws.moneyApply'); 
        });


        Route::name('setting.')->group(function(){
        Route::get('/profile-setting', 'GatewaySettings@getProfile')->name('setting.profile-setting');
        Route::get('/change-password', 'GatewaySettings@getChangepwd')->name('setting.change-password'); 
        Route::get('/api-key', 'GatewaySettings@getApikey')->name('setting.api-key'); 
        Route::get('/ip-allow', 'GatewaySettings@getIP')->name('setting.ip-allow');
        Route::post('/ip-allow/store', 'GatewaySettings@IPstore')->name('setting.store');
        Route::delete('/ip-allow/{id}', 'GatewaySettings@IPdestroy')->name('setting.destroy');
        
        Route::get('/help-account', 'GatewaySettings@getHelp')->name('setting.help');
        Route::post('/help-account/store', 'GatewaySettings@Helpstore')->name('setting.help-store');
        Route::delete('/help-account/{id}', 'GatewaySettings@Helpdestroy')->name('setting.help-destroy');
    
        });
        
        Route::name('gateway.')->group(function(){
        Route::get('/methods', 'GatewaySettings@getMethods')->name('gateway.methods');
        });
        
        Route::get('/financial-records', 'PayoutBDController@getFinancialRecords')->name('financial-records');
        Route::get('/processDeposit', 'DashboardController@processDeposit')->name('processDeposit');
        
        Route::get('/calculate-charge', 'GatewaySettings@getCalculateCharge')->name('calculate-charge');
        Route::get('/export', 'GatewaySettings@getExport')->name('data-export');
        Route::get('/getDownload', 'GatewaySettings@getDownload')->name('data-download');
        
      });



});        