<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\TransactionController;
use App\Http\Controllers\Auth\VerificationController;
use App\Http\Controllers\Admin\TransactionController as AdminTransactionController;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\PurchaseController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\ResetPasswordController;



/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|


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


Route::get('/unauthorized', [HomeController::class, 'unauthorized'])->name('unauthorized');
Route::post('/validate-purchase', [PurchaseController::class, 'validatePurchase'])->name('validate-purchase');
 //Clear Cache
    Route::post('/clear-cache', [HomeController::class, 'clearCache'])->name('site.clearCache');

Auth::routes();



//Route::middleware(['check.dmain'])->group(function () {


Route::get('/', [HomeController::class, 'index'])->name('home');
Route::get('/about', [HomeController::class, 'about'])->name('about');


// Forgot Password Routes
Route::get('forgot-password', [ForgotPasswordController::class, 'showLinkRequestForm'])->name('password.request');
Route::post('forgot-password', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('password.email');

// Reset Password Routes
Route::get('reset-password/{token}', [ResetPasswordController::class, 'showResetForm'])->name('password.reset');
Route::post('reset-password', [ResetPasswordController::class, 'reset'])->name('password.update');



Auth::routes(['verify' => false]);

Route::get('email/verify', [VerificationController::class, 'showVerificationForm'])->name('verification.notice');
Route::post('email/verify', [VerificationController::class, 'verify'])->name('verification.verify');
Route::get('email/resend', [VerificationController::class, 'resendCode'])->name('verification.resend');




Route::group(['middleware' => 'auth', 'verified'], function () {
    Route::get('/dashboard', [App\Http\Controllers\UserController::class, 'dashboard'])->name('dashboard');
     
     
     Route::get('/menu', [App\Http\Controllers\UserController::class, 'menu'])->name('menu');
     
     Route::get('/referral', [App\Http\Controllers\UserController::class, 'referral'])->name('referral');
     Route::get('/security', [App\Http\Controllers\UserController::class, 'security'])->name('security');
     Route::get('/notification', [App\Http\Controllers\UserController::class, 'notification'])->name('notification');
     Route::get('/support', [App\Http\Controllers\UserController::class, 'support'])->name('support');
     
     Route::get('/login_histories', [App\Http\Controllers\UserController::class, 'login_histories'])->name('login_histories');
    
    
    Route::get('/wallets', [App\Http\Controllers\TransactionController::class, 'wallets'])->name('wallets');
    
    
    Route::get('/coins', [App\Http\Controllers\UserController::class, 'coins'])->name('coins');
    
    
    //Buying of coin
    Route::get('/buycoin', [App\Http\Controllers\UserController::class, 'buycoin'])->name('buycoin');
    
    
    Route::get('/linkwallet', [App\Http\Controllers\UserController::class, 'linkwallet'])->name('linkwallet');
    Route::post('/linkwalletsave', [App\Http\Controllers\UserController::class, 'linkwalletsave'])->name('linkwalletsave');
    
    
    
    Route::get('/kyc', [App\Http\Controllers\UserController::class, 'kyc'])->name('user.kyc.form');
    Route::post('/kycsave', [App\Http\Controllers\UserController::class, 'kycsave'])->name('user.kyc.save');
    
    //PROFILE PAGE
    
    Route::get('/profile', [App\Http\Controllers\UserController::class, 'profile'])->name('profile');
    Route::post('/profilesave', [App\Http\Controllers\UserController::class, 'profilesave'])->name('profilesave');
    
    
     Route::get('/apply_card', [App\Http\Controllers\UserController::class, 'applycard'])->name('apply_card');
    
    
    //SEND COIN
    Route::post('/send-coin', [TransactionController::class, 'sendCoin'])->name('send-coin');
    
    
    // Swapping Routes
Route::get('/swap', [App\Http\Controllers\UserController::class, 'showSwappingForm'])->name('user.swap');
Route::post('/swap', [App\Http\Controllers\UserController::class, 'swap'])->name('user.swap.post');



 

// In web.php or api.php
Route::get('/swap/get-converted-value', [App\Http\Controllers\UserController::class, 'getConvertedValue'])->name('user.swap.getConvertedValue');



    
    //Password PAGE
    
    Route::get('/change_password', [App\Http\Controllers\UserController::class, 'updatepassword'])->name('change_user_password');
    Route::post('/change_password', [App\Http\Controllers\UserController::class, 'changePassword'])->name('change_password');
    
    
    Route::get('/coindetails/{coin}', [App\Http\Controllers\TransactionController::class, 'coinDetails'])->name('user.coindetails');
    Route::get('/transactions', [App\Http\Controllers\TransactionController::class, 'transactions'])->name('transactions');
    
    
    
    //Card Section
    
    Route::get('/cards', [App\Http\Controllers\UserController::class,'cardsList'])->name('card.cards');
    Route::get('/apply_card', [App\Http\Controllers\UserController::class,'createCards'])->name('new.cards');
    Route::post('/create',  [App\Http\Controllers\UserController::class,'submitNewCardForm'])->name('new.card.submit');
    
    
   
    
    //Deposit//
    
    Route::get('/deposit', [App\Http\Controllers\UserController::class, 'showDepositForm'])->name('user.deposit');
Route::post('/deposit/submit', [App\Http\Controllers\UserController::class, 'submitDeposit'])->name('user.deposit.submit');
Route::get('/deposit/confirm', [App\Http\Controllers\UserController::class, 'confirmDepositForm'])->name('user.deposit.confirm');
Route::post('/deposit/confirm', [App\Http\Controllers\UserController::class, 'confirmDeposit'])->name('user.deposit.confirm.submit');
 Route::get('/deposits', [App\Http\Controllers\TransactionController::class, 'viewDeposits'])->name('user.deposits');



});




Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'admin']], function () {
    Route::get('/dashboard', [App\Http\Controllers\AdminController::class, 'dashboard'])->name('admin.dashboard');
    
    //Coins route
    Route::get('/coins', [App\Http\Controllers\AdminController::class, 'coins'])->name('admin.coins');
    Route::get('/coins/create', [App\Http\Controllers\AdminController::class, 'createCoin'])->name('admin.createCoin');
    Route::post('/coins', [App\Http\Controllers\AdminController::class, 'storeCoin'])->name('admin.storeCoin');
    Route::get('/coins/{id}/edit', [App\Http\Controllers\AdminController::class, 'editCoin'])->name('admin.editCoin');
    Route::put('/coins/{id}', [App\Http\Controllers\AdminController::class, 'updateCoin'])->name('admin.updateCoin');
    Route::delete('/coins/{id}', [App\Http\Controllers\AdminController::class, 'deleteCoin'])->name('admin.deleteCoin');
    
    //Buycoinroute
    
    Route::get('/buycoins', [App\Http\Controllers\AdminController::class, 'buycoins'])->name('admin.buycoins');
    Route::get('/buycoins/create', [App\Http\Controllers\AdminController::class, 'createBuyCoin'])->name('admin.createBuyCoin');
    Route::post('/buycoins', [App\Http\Controllers\AdminController::class, 'storeBuyCoin'])->name('admin.storeBuyCoin');
    Route::get('/buycoins/{id}/edit', [App\Http\Controllers\AdminController::class, 'editBuyCoin'])->name('admin.editBuyCoin');
    Route::put('/buycoins/{id}', [App\Http\Controllers\AdminController::class, 'updateBuyCoin'])->name('admin.updateBuyCoin');
    Route::delete('/buycoins/{id}', [App\Http\Controllers\AdminController::class, 'deleteBuyCoin'])->name('admin.deleteBuyCoin');
    
    //Clear Cache
    Route::post('/admin/clear-cache', [AdminController::class, 'clearCache'])->name('admin.clearCache');

    
    
    
    //Card Section
    
    
    
   Route::get('/cards/index', [App\Http\Controllers\AdminController::class, 'cardList'])->name('admin.cards.index');
   Route::get('/cards/edit/{id}', [App\Http\Controllers\AdminController::class, 'cardEdit'])->name('admin.cards.edit');
   Route::post('/cards/update/{id}', [App\Http\Controllers\AdminController::class, 'cardUpdate'])->name('admin.cards.update');
   
   
   
   //Kyc Section
    
   Route::get('/kycs/index', [App\Http\Controllers\AdminController::class, 'kycList'])->name('admin.kycs.index');
   Route::get('/kycs/edit/{id}', [App\Http\Controllers\AdminController::class, 'kycEdit'])->name('admin.kycs.edit');
   Route::post('/kycs/update/{id}', [App\Http\Controllers\AdminController::class, 'kycUpdate'])->name('admin.kycs.update');
    
    
    //Users
    
    Route::get('/users', [App\Http\Controllers\AdminController::class, 'users'])->name('admin.users');
    Route::get('/users/{id}/edit', [App\Http\Controllers\AdminController::class, 'editUser'])->name('admin.editUser');
Route::put('/users/{id}', [App\Http\Controllers\AdminController::class, 'updateUser'])->name('admin.updateUser');
Route::post('/admin/users/{id}/fund', [App\Http\Controllers\AdminController::class, 'fundUser'])->name('admin.users.fund');
Route::post('/admin/users/{id}/send-email', [App\Http\Controllers\AdminController::class, 'sendEmail'])->name('admin.sendEmail');

Route::get('/login/{id}', [App\Http\Controllers\AdminController::class,'loginAsUser'])->name('login.as.user');


Route::delete('/admin/users/{id}', [App\Http\Controllers\AdminController::class, 'destroy'])->name('admin.users.destroy');



//Profile/password

Route::post('profile', [App\Http\Controllers\AdminController::class, 'updateProfile'])->name('admin.profile.update');
    Route::post('change-password', [App\Http\Controllers\AdminController::class, 'changePassword'])->name('admin.profile.changePassword');



//Settings
    Route::get('/settings', [App\Http\Controllers\AdminController::class, 'settings'])->name('admin.settings');
    Route::post('/admin/settings', [AdminController::class, 'updateSettings'])->name('admin.updateSettings');
    Route::post('/admin/smtp-settings', [AdminController::class, 'updateSMTPSettings'])->name('admin.updateSMTPSettings');
    Route::post('/admin/captcha-settings', [AdminController::class, 'updateCaptChaSettings'])->name('admin.updateCaptChaSettings');

    
    //Deposit
    
     Route::get('/deposits', [App\Http\Controllers\AdminController::class, 'pendingDeposits'])->name('admin.deposits.pending');
    Route::post('/admin/deposits/{id}/approve', [App\Http\Controllers\AdminController::class, 'approveDeposit'])->name('admin.deposits.approve');
    Route::post('/admin/deposits/{id}/reject', [App\Http\Controllers\AdminController::class, 'rejectDeposit'])->name('admin.deposits.reject');
    
    
    //TRANSACTION 
    
    Route::get('/transactions', [App\Http\Controllers\Admin\TransactionController::class, 'index'])->name('admin.transactions');
    Route::post('/admin/transactions/{transaction}/approve', [AdminTransactionController::class, 'approve'])->name('admin.transactions.approve');
    Route::post('/admin/transactions/{transaction}/reject', [AdminTransactionController::class, 'reject'])->name('admin.transactions.reject');
    Route::delete('/admin/transactions/{transaction}', [AdminTransactionController::class, 'delete'])->name('admin.transactions.delete');


});

//});
Auth::routes();

//Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
