<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Web\WebController;
use App\Http\Controllers\Web\CartController;

use App\Http\Controllers\Member\MemberController;
use App\Http\Controllers\Member\BuyingController;
use App\Http\Controllers\Member\ReportController;
use App\Http\Controllers\Member\WalletController;

use App\Http\Controllers\Vendor\VendorController;
use App\Http\Controllers\Vendor\ShopController;

use App\Http\Controllers\Agent\AgentController;
use App\Http\Controllers\Agent\SalesController;

use App\Http\Controllers\Admin\AdminController;
use App\Http\Controllers\Admin\ManageController;
use App\Http\Controllers\Admin\PaymentController;
use App\Http\Controllers\Admin\ProductController;
use App\Http\Controllers\Admin\ContentController;

use App\Http\Controllers\BonusController;
use App\Http\Controllers\StatusController;
use App\Http\Controllers\Controller;


// Cache Clear ///////////////////////////////////
Route::get('/cache_set', function() {
    $exitCode = Artisan::call('config:cache');
    return 'Config cache set';
}); 

Route::get('/cache_clear', function() {
    $exitCode = Artisan::call('config:clear');
    return 'Config cache cleared';
});


// Web Routes ///////////////////////////////////////////////////////////////
Route::get('/', [WebController::class, 'index']);
Route::get('login', [WebController::class, 'login']);
Route::match(['get','post'],'userlogin', [WebController::class, 'accountLogin']);

Route::get('passreset', [WebController::class, 'passreset']);
Route::match(['get','post'],'resetpass', [WebController::class, 'resetpass']);

Route::get('admin', [WebController::class, 'admin']);
Route::match(['get','post'],'adminlogin', [WebController::class, 'adminLogin']);

// Pages
Route::get('about', [WebController::class, 'about']);
Route::get('gallery', [WebController::class, 'gallery']);
Route::get('news', [WebController::class, 'news']);
Route::get('postdetails/{id}', [WebController::class, 'postdetails']);
Route::get('contact', [WebController::class, 'contact']);
Route::match(['get','post'],'contactus', [WebController::class, 'contactus']);
Route::match(['get','post'],'subscribe', [WebController::class, 'subscribe']);
Route::get('faqs', [WebController::class, 'faqs']);
Route::get('privacy', [WebController::class, 'privacy']);
Route::get('terms', [WebController::class, 'terms']);

// Product
Route::get('cat-{id}', [WebController::class, 'catPro']);
Route::get('prodetails/{id}', [WebController::class, 'prodetails']);

// Cart
Route::get('cart', [CartController::class, 'cart']);
Route::match(['get','post'],'addtocart', [CartController::class, 'addtocart']);
Route::get('cdelete/{id}', [CartController::class, 'cdelete']);
Route::get('invoice{id}', [CartController::class, 'invoice']);

// Register
Route::get('register', [WebController::class, 'register']);
Route::get('ref/{data}', [WebController::class, 'registration']);
Route::post('check/refer', [WebController::class, 'referAbility'])->name('chkrefer');
Route::post('check/user', [WebController::class, 'UserAbility'])->name('chkuser');
Route::match(['get','post'],'user/register', [WebController::class, 'newRegister']);

// Cron Routes ////////////////////////////////////////////////////////////////
Route::get('daily/status', [StatusController::class, 'dailyStatus']);

// Member Routes //////////////////////////////////////////////////////////////
Route::prefix('/')->namespace('Member')->group(function(){
    Route::group(['middleware'=>['member']],function(){
        Route::get('dashboard', [MemberController::class, 'dashboard']);
        Route::get('profile', [MemberController::class, 'profile']);          
        Route::get('logout', [MemberController::class, 'logout']);

        // Settings
        Route::get('settings', [MemberController::class, 'settings']);
        Route::match(['get','post'], 'profileupdate', [MemberController::class, 'profileUpdate']);
        Route::get('kyc', [MemberController::class, 'kyc']);
        Route::match(['get','post'], 'kycsubmit', [MemberController::class, 'kycsubmit']);
        Route::post('updatepass', [MemberController::class, 'updatePass']);
        Route::post('pingenerate', [MemberController::class, 'pinGenerate']);
        Route::post('updatepin', [MemberController::class, 'updatePin']);
        Route::match(['get','post'], 'secreset', [MemberController::class, 'secreset']);

        // Voucher
        Route::get('voucher', [BuyingController::class, 'voucher']);
        Route::get('voustatus', [BuyingController::class, 'viewvou']);
        Route::match(['get','post'], 'buyvoucher', [BuyingController::class, 'buyvoucher']);

        // Earning Tools, Level, Group Card, Savings
        Route::get('etools', [BuyingController::class, 'etools']);
        Route::match(['get','post'], 'activelvl', [BuyingController::class, 'activelvl']);

        // Cart
        Route::get('checkout', [BuyingController::class, 'checkout']);
        Route::match(['get','post'], 'addaddress', [BuyingController::class, 'addAddress']);
        Route::get('deltship/{id}', [BuyingController::class, 'dltAddress']);
        Route::match(['get','post'], 'updateship', [BuyingController::class, 'updateship']);
        Route::get('delivery', [BuyingController::class, 'delivery']);
        Route::match(['get','post'], 'pkupupdate', [BuyingController::class, 'pkupupdate']);
        Route::get('cartpay', [BuyingController::class, 'cartpay']);
        Route::match(['get','post'], 'buyaction', [BuyingController::class, 'completeOrder']);
        Route::get('complete', [BuyingController::class, 'complete']);

        // Buying
        Route::get('pack', [BuyingController::class, 'pack']);
        Route::get('buypak{id}', [BuyingController::class, 'buypak']);
        Route::match(['get','post'], 'buypk', [BuyingController::class, 'buypkAction']);
        Route::match(['get','post'], 'ptrnsfer', [BuyingController::class, 'ptrnsfer']);
        Route::get('orders', [BuyingController::class, 'orders']);
        Route::get('invoice/{id}', [BuyingController::class, 'invoice']);
        Route::get('pkstatus', [BuyingController::class, 'pkstatus']);

        // Affiliate
        Route::get('affiliates', [MemberController::class, 'referrals']);
        Route::get('refview-{id}', [MemberController::class, 'refView']);
       
        // Payment
        Route::get('addfund', [WalletController::class, 'addfund']);
        Route::get('afbks', [WalletController::class, 'afbks']);
        Route::get('afngd', [WalletController::class, 'afngd']);
        Route::get('afrckt', [WalletController::class, 'afrckt']);
        Route::get('afupay', [WalletController::class, 'afupay']);
        Route::match(['get','post'], 'addfaction', [WalletController::class, 'addfAction']);

        Route::get('convert', [WalletController::class, 'convert']);
        Route::match(['get','post'], 'cashconv', [WalletController::class, 'cashConvert']);

        Route::get('ctrans', [WalletController::class, 'ctrans']);
        Route::match(['get','post'], 'cwsend', [WalletController::class, 'cwTrans']);

        Route::get('payout', [WalletController::class, 'payout']);
        Route::match(['get','post'], 'balpay', [WalletController::class, 'balPayout']);

        // Reports
        Route::get('report', [ReportController::class, 'report']);
        Route::match(['get','post'], 'reposrch', [ReportController::class, 'reposrch']);
       
    });

});


// Admin Routes ///////////////////////////////////////////////////////////////////
Route::prefix('/admin')->namespace('admin')->group(function(){
    Route::group(['middleware'=>['admin']],function(){
        Route::get('dashboard', [AdminController::class, 'dashboard']);
        Route::get('logout', [AdminController::class, 'logout']);
        
        // Settings
        Route::get('settings', [AdminController::class, 'settings']);
        Route::match(['get','post'], 'updateprofile', [AdminController::class, 'updateProfile']);
        Route::post('updatepass', [AdminController::class, 'updatePass']);
        Route::post('updatepin', [AdminController::class, 'updatePin']);
        Route::match(['get','post'], 'secreset', [AdminController::class, 'secreset']);
        Route::match(['get','post'], 'ponoff', [AdminController::class, 'ponoff']);
        
        // Product
        Route::get('categories', [ProductController::class, 'categories']);
        Route::match(['get','post'], 'addcat', [ProductController::class, 'addCat']);
        Route::get('catedit/{id}', [ProductController::class, 'catedit']);
        Route::match(['get','post'], 'editcat', [ProductController::class, 'editCat']);

        Route::get('addpro', [ProductController::class, 'addpro']);
        Route::match(['get','post'], 'addpronow', [ProductController::class, 'addpronow']);

        Route::get('products', [ProductController::class, 'proList']);
        Route::get('promng/{id}', [ProductController::class, 'proMng']);
        Route::match(['get','post'], 'proedit', [ProductController::class, 'proEdit']);

        // Contant
        Route::get('addpost', [ContentController::class, 'addpost']);
        Route::match(['get','post'], 'addpostnow', [ContentController::class, 'addpostnow']);

        Route::get('posts', [ContentController::class, 'postList']);
        Route::get('postmng/{id}', [ContentController::class, 'postMng']);
        Route::match(['get','post'], 'postedit', [ContentController::class, 'postEdit']);

        // Orders
        Route::get('pendord', [ManageController::class, 'pendOrd']);
        Route::get('ordmng/{id}', [ManageController::class, 'ordMng']);
        Route::match(['get','post'], 'ordprocess', [ManageController::class, 'ordProcess']);
        Route::get('paidord', [ManageController::class, 'paidOrd']);
        Route::get('invoice/{id}', [ManageController::class, 'invoice']);
        Route::get('cbstatus', [ManageController::class, 'cbstatus']);

        // Member routes
        Route::get('members', [ManageController::class, 'members']);
        Route::get('exmem', [ManageController::class, 'exmem']);
        Route::get('mnmem', [ManageController::class, 'mnmem']);
        Route::get('fndmem', [ManageController::class, 'fndmem']);
        Route::get('blockmem', [ManageController::class, 'blockmembers']);
        Route::get('memdata', [ManageController::class, 'memdata']);
        Route::match(['get','post'], 'memview', [ManageController::class, 'memview']);
        Route::get('memdata/{id}', [ManageController::class, 'memdataView']);
        Route::get('memedit', [ManageController::class, 'memedit']);
        Route::match(['get','post'],'editmem', [ManageController::class, 'editMem']);
        Route::get('memedit/{id}', [ManageController::class, 'memberEdit']);
        Route::match(['get','post'], 'meminfoedit', [ManageController::class, 'meminfoedit']);
        Route::match(['get','post'], 'passupdate', [ManageController::class, 'passupdate']);
        Route::match(['get','post'], 'pingenerate', [ManageController::class, 'pingenerate']);
        Route::match(['get','post'], 'pinupdate', [ManageController::class, 'pinupdate']); 
        Route::get('block', [ManageController::class, 'block']);
        Route::match(['get','post'], 'blockunblock', [ManageController::class, 'blockunblock']); 

        // KYC
        Route::get('kycrq', [ManageController::class, 'kycrq']);
        Route::get('kycmng/{id}', [ManageController::class, 'kycmng']);
        Route::match(['get','post'], 'kycmng/aprov', [ManageController::class, 'kycmngAprov']);
        Route::get('kycs', [ManageController::class, 'kycs']);

        // Vendors  
        Route::get('vendors', [ManageController::class, 'vendors']);  
        Route::get('addvendor', [ManageController::class, 'addvendor']);
        Route::post('check/vend', [ManageController::class, 'vendorAbility'])->name('chkvend');
        Route::match(['get','post'], 'vendregi', [ManageController::class, 'vendregi']);

        // Payment routes
        Route::get('balreq', [PaymentController::class, 'balreq']);
        Route::get('afmng/{id}', [PaymentController::class, 'afMang']);
        Route::match(['get','post'],'afmng/paid', [PaymentController::class, 'reqbTrans']);
        
        Route::get('balsend', [PaymentController::class, 'balsend']);
        Route::match(['get','post'],'bal/send', [PaymentController::class, 'balTrans']);
        
        Route::get('pendpay', [PaymentController::class, 'pendpay']);
        Route::get('paymng/{id}', [PaymentController::class, 'payMang']);
        Route::match(['get','post'],'paymng/paid', [PaymentController::class, 'paymngPaid']);
        Route::get('paidpay', [PaymentController::class, 'paidpay']);

        // Report Routes
        Route::get('reports', [AdminController::class, 'reports']);
        Route::match(['get','post'],'reposerch', [AdminController::class, 'reposerch']);
        Route::get('afrepo', [AdminController::class, 'afrepo']);
        Route::get('trnsrepo', [AdminController::class, 'trnsrepo']);

        // Ranks
        Route::get('agm', [ManageController::class, 'agm']);
        Route::get('dgm', [ManageController::class, 'dgm']);
        Route::get('gm', [ManageController::class, 'gm']);
        Route::get('ed', [ManageController::class, 'ed']);
        Route::get('dirc', [ManageController::class, 'dirc']);


        // Message
        Route::get('smsg', [AdminController::class, 'smsg']);
        Route::match(['get','post'],'msg/send', [AdminController::class, 'messageSend']);
        Route::get('msg', [AdminController::class, 'message']);
        Route::match(['get','post'],'msg/done', [AdminController::class, 'messageDone']);
        Route::get('msg/dlt/{id}', [AdminController::class, 'messageDLT']);
        Route::get('msg/reply/{id}', [AdminController::class, 'msgReply']);
        Route::match(['get','post'],'mesgreply', [AdminController::class, 'msgReplyAction']);
        Route::get('cmsg', [AdminController::class, 'cmsg']);


    });

});