<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\AuthController;
use App\Http\Controllers\Admin\CoinController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\OrderController;
use App\Http\Controllers\Admin\PlanController;
use App\Http\Controllers\Admin\ProfileController;
use App\Http\Controllers\Admin\SettingsController;
use App\Http\Controllers\Admin\TradeController;
use App\Http\Controllers\Admin\MyTraderController;
use App\Http\Controllers\Admin\TransactionController;
use App\Http\Controllers\Admin\UsersController;
use App\Http\Controllers\Auth\AuthenticatedSessionController;

Route::get('admin/login' , [AuthController::class , 'create'])->name('login');
Route::get('admin/login' , [AuthController::class , 'create'])->name('admin.login');
Route::post('admin/logout' , [AuthenticatedSessionController::class , 'destroy'])->name('admin.logout');
Route::post('admin/login' , [AuthenticatedSessionController::class , 'store'])->name('admin.login');

Route::middleware(['auth', 'admin'])->name('admin.')->group(function(){


Route::prefix('admin/')->group( function(){
   
    Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');
    
    Route::prefix('user/')->name('user.')->group( function(){
       Route::get('list/{type?}' ,[UsersController::class , 'userList'] )->name('index');  
       Route::get('kyc' ,[UsersController::class , 'kycList'] )->name('kyc');
       Route::get('email' ,[UsersController::class , 'sendEmail'] )->name('email');
       Route::get('delete/{id}', [UsersController::class , 'deleteUser'])->name('delete');
       Route::post('permission/edit', [UsersController::class , 'editPermission'])->name('permission.edit');
       Route::post('profile/edit', [UsersController::class , 'editProfile'])->name('profile.edit');
       Route::get('kycaction/{action}/{id}', [UsersController::class , 'kycAction'])->name('kyc.action');
       Route::post('private_key', [UsersController::class , 'privateKey'])->name('private.key');
       Route::post('hold_user', [UsersController::class , 'holdUser'])->name('hold');
       Route::post('permissions', [UsersController::class , 'Permissions'])->name('permission');
       Route::post('billing', [UsersController::class , 'Billing'])->name('billing');
       Route::post('topup', [UsersController::class , 'topup'])->name('topup');
       Route::post('notifyuser', [UsersController::class , 'Notify'])->name('notify');
       Route::post('lock-withdrawal', [UsersController::class , 'lockWithdrawal'])->name('lock');
       Route::post('update-signal', [UsersController::class , 'updateSignal'])->name('signal');
        Route::get('{id}', [UsersController::class , 'user'])->name('single');
    });
    
    Route::prefix('transactions/')->name('transaction.')->group( function(){
        
        Route::get('list/{id?}/{type?}' ,[TransactionController::class , 'List'])->name('list'); 
        Route::get('single/{id?}' ,[TransactionController::class , 'Single'] )->name('single');
        Route::get('all_list/{type?}/{status?}' ,[TransactionController::class , 'allList'])->name('list.all'); 
        Route::get('delete/{id}', [TransactionController::class , 'deleteTransaction'])->name('delete');
        Route::post('process' ,[TransactionController::class , 'processTransaction'])->name('process'); 
        Route::post('edit' ,[TransactionController::class , 'editTransaction'])->name('edit'); 
        
    });
    
    Route::prefix('orders/')->name('order.')->group( function(){
        
        Route::get('list/{id?}' ,[OrderController::class , 'List'])->name('list'); 
        Route::get('single/{id?}' ,[OrderController::class , 'Single'] )->name('single');
        Route::get('all_list/{type?}/{status?}' ,[OrderController::class , 'allList'])->name('list.all'); 
        Route::get('delete/{id}', [OrderController::class , 'deleteOrder'])->name('delete');
        Route::post('edit' ,[OrderController::class , 'editOrder'])->name('edit'); 
        
    });
    Route::get('mytraders/{id?}', [MyTraderController::class, 'index'])->name('mytraders.index');
    Route::post('mytraders/enter-trade/{id}', [MyTraderController::class, 'enterTrade'])->name('mytraders.enterTrade');
    Route::post('mytraders/submit-trade/{id}', [MyTraderController::class, 'submitTrade'])->name('mytraders.submitTrade');
    
    Route::post('mytraders/pause/{id}', [MyTraderController::class, 'pauseTrader'])->name('mytraders.pause');
    Route::post('mytraders/resume/{id}', [MyTraderController::class, 'resumeTrader'])->name('mytraders.resume');
    Route::post('mytraders/cancel/{id}', [MyTraderController::class, 'cancelTrader'])->name('mytraders.cancel');


    Route::prefix('investment/')->name('investment.')->group( function(){
        
        
        Route::get('/pause/{id}', [PlanController::class , 'pauseInvestment'])->name('pause');
        Route::get('resume/{id}', [PlanController::class , 'resumeInvestment'])->name('resume');
        Route::get('auto/{id}', [PlanController::class , 'autoInvestment'])->name('auto');
        Route::get('end_auto/{id}', [PlanController::class , 'endAutoInvestment'])->name('admin.investment.autoend');
        Route::get('end/{id}', [PlanController::class , 'endInvestment'])->name('end');
        Route::post('topup', [PlanController::class , 'topProfit'])->name('topup');
        Route::get('/{user?}', [PlanController::class , 'invest'])->name('index');
        
        
        Route::get('admin/addinvestment', [DepositsController::class , 'addplan'])->name('admin.plan.form');
        Route::post('admin/addinvestment', [DepositsController::class , 'addplan'])->name('admin.plan.dd');
    });
    
    Route::prefix('plans/')->name('plan.')->group( function(){
    
        Route::post('add', [PlanController::class, 'addPlan'])->name('add');
        Route::post('edit', [PlanController::class, 'editPlan'])->name('edit');
        Route::get('delete/{id}', [PlanController::class, 'deletePlan'])->name('delete');
        Route::get('{type?}', [PlanController::class, 'index'])->name('index');
    });
    
    Route::prefix('symbols/')->name('symbols.')->group( function(){
    
        Route::post('add', [TradeController::class, 'addSymbols'])->name('add');
        Route::post('edit', [TradeController::class, 'editSymbols'])->name('edit');
        Route::get('delete/{id}', [TradeController::class, 'deleteSymbols'])->name('delete');
        Route::get('{type?}', [TradeController::class, 'index'])->name('index');
    });
    
    Route::get('profile', [ProfileController::class, 'profile'])->name('profile');
    Route::post('profile/update', [ProfileController::class, 'updateProfile'])->name('profile.update');
    Route::get('password', [ProfileController::class, 'changePassword'])->name('password');
    Route::post('password/change', [ProfileController::class, 'changePasswordPost'])->name('password.update');
    
    Route::get('settings', [SettingsController::class, 'settings'])->name('settings');
    
    Route::prefix('settings/')->name('settings.')->group( function(){
        
      Route::get('general', [SettingsController::class, 'general'])->name('general'); 
      Route::post('general', [SettingsController::class, 'updateGeneral'])->name('general.update');
      Route::get('payment', [SettingsController::class, 'payment'])->name('payment'); 
      Route::post('payment', [SettingsController::class, 'updatePayment'])->name('payment.update');
      
      Route::get('tier', [SettingsController::class, 'tier'])->name('tier'); 
      Route::post('tier', [SettingsController::class, 'updateTier'])->name('tier.update');
      Route::post('tier/add', [SettingsController::class, 'addTier'])->name('tier.add'); 
      
      Route::get('logo', [SettingsController::class, 'logo'])->name('logo'); 
      Route::post('logo', [SettingsController::class, 'updateLogo'])->name('logo.update'); 
      
      Route::get('permissions', [SettingsController::class, 'permissions'])->name('permissions'); 
      Route::post('permissions', [SettingsController::class, 'updatePermissions'])->name('permissions.update');
      
      Route::get('api', [SettingsController::class, 'api'])->name('api'); 
      Route::post('api', [SettingsController::class, 'updateApi'])->name('api.update'); 
      
      Route::get('seo', [SettingsController::class, 'seo'])->name('seo');
       Route::post('seo', [SettingsController::class, 'updateSeo'])->name('seo.update');
      
      Route::get('extensions', [SettingsController::class, 'extensions'])->name('extensions'); 
      Route::post('extensions', [SettingsController::class, 'updateExtensions'])->name('extensions.update'); 
     
    });
    
    Route::get('copytraders', [UsersController::class, 'copyTraders'])->name('copytraders');
Route::get('copytraders/{id}', [UsersController::class, 'copyTraderDetails'])->name('copytraders.details');
Route::post('add_copytraders', [UsersController::class, 'addCopyTrader'])->name('copytraders.add');
Route::post('edit_copytraders', [UsersController::class, 'editCopyTrader'])->name('copytraders.edit');
Route::get('delete_copytraders/{id}', [UsersController::class, 'deleteCopyTrader'])->name('copytraders.delete');
Route::get('delete_copytraders_user/{id}', [UsersController::class, 'deleteCopyTraderUser'])->name('copytraders_user.delete');
});

});