<?php

use Illuminate\Support\Facades\Route;

Route::prefix('admin')->name('admin.')->middleware(['admin'])->group(function () {
    Route::get('/dashboard', [\App\Http\Controllers\Admin\DashboardController::class, 'index'])->name('admin.dashboard.index');
    Route::get('/chart/load', [\App\Http\Controllers\Admin\ChartController::class, 'loadChart']);
    Route::get('/chart/load/{userId}', [\App\Http\Controllers\Admin\ChartController::class, 'loadChartUser']);
    Route::get('/postback-list', [\App\Http\Controllers\Admin\PostbacksController::class, 'create'])->name('postback');
    Route::post('/postback-save', [\App\Http\Controllers\Admin\PostbacksController::class, 'store'])->name('postback.store');
    
    // settings
    Route::get('/settings', [\App\Http\Controllers\Admin\SettingsController::class, 'index'])->name('admin.settings.index');
    Route::get('/setting/{setting}', [\App\Http\Controllers\Admin\SettingsController::class, 'index']);
    Route::post('/settings/update', [\App\Http\Controllers\Admin\SettingsController::class, 'update'])->name('admin.settings.update');
    Route::get('/settings/upload', [\App\Http\Controllers\Admin\SettingsController::class, 'uploadFile']);
    Route::post('/settings/upload/{type}', [\App\Http\Controllers\Admin\SettingsController::class, 'uploadFile']);
    Route::get('/remove/{type}', [\App\Http\Controllers\Admin\SettingsController::class, 'removeFile']);
    Route::post('/settings/revert', [\App\Http\Controllers\Admin\SettingsController::class, 'revertFile']);
    
    // shortlinks
    Route::get('/links/load', [\App\Http\Controllers\Admin\LinkController::class, 'load']);
    Route::post('/link/add', [\App\Http\Controllers\Admin\LinkController::class, 'store']);
    Route::get('/link/edit/{id}', [\App\Http\Controllers\Admin\LinkController::class, 'edit']);
    Route::put('/link/update/{id}', [\App\Http\Controllers\Admin\LinkController::class, 'update']);
    Route::delete('/link/delete/{id}', [\App\Http\Controllers\Admin\LinkController::class, 'destroy']);
    
    //contest
    Route::get('/contest/load', [\App\Http\Controllers\Admin\ContestController::class, 'load']);
    Route::put('/contest/update/{id}', [\App\Http\Controllers\Admin\ContestController::class, 'update']);
    // currency
    Route::get('/currency/load', [\App\Http\Controllers\Admin\CurrencyController::class, 'load']);
    Route::post('/currency/add', [\App\Http\Controllers\Admin\CurrencyController::class, 'store']);
    Route::delete('/currency/delete/{id}', [\App\Http\Controllers\Admin\CurrencyController::class, 'delete']);
    Route::get('/withdraw/load', [\App\Http\Controllers\Admin\CurrencyController::class, 'loadOption']);
    Route::post('/withdraw/add', [\App\Http\Controllers\Admin\CurrencyController::class, 'storeOption']);
    Route::put('/withdraw/update/{id}', [\App\Http\Controllers\Admin\CurrencyController::class, 'updateOption']);
    Route::delete('/withdraw/delete/{id}', [\App\Http\Controllers\Admin\CurrencyController::class, 'deleteOption']);
    
    //users
    Route::get('/users', [\App\Http\Controllers\Admin\UsersController::class, 'index']);
    Route::post('/users/add', [\App\Http\Controllers\Admin\UsersController::class, 'store']);
    Route::put('/users/edit', [\App\Http\Controllers\Admin\UsersController::class, 'update']);
    Route::get('/users/load', [\App\Http\Controllers\Admin\UsersController::class, 'load']);
    Route::put('/users/toggle-ban', [\App\Http\Controllers\Admin\UsersController::class, 'toggleBan']);
    Route::get('/user/{id}', [\App\Http\Controllers\Admin\UsersController::class, 'info']);
    Route::post('/user/update-balance/{id}', [\App\Http\Controllers\Admin\UsersController::class, 'updateBalance']);
    Route::get('/referrals/load', [\App\Http\Controllers\Admin\UsersController::class, 'loadReferral']);
    
    //advertiser.ptc
    Route::get('/advertise/ptc', [\App\Http\Controllers\Admin\PtcController::class, 'index']);
    Route::get('/advertise/ptc/load/{status}', [\App\Http\Controllers\Admin\PtcController::class, 'fetchAds']);
    Route::post('/advertise/ptc/store', [\App\Http\Controllers\Admin\PtcController::class, 'store']);
    Route::post('/advertise/ptc/update-status', [\App\Http\Controllers\Admin\PtcController::class, 'updateStatus']);

    //advertiser.link
    Route::get('/advertise/link', [\App\Http\Controllers\Admin\LinkController::class, 'advertise']);
    Route::get('/advertise/link/load/{status}', [\App\Http\Controllers\Admin\LinkController::class, 'fetchAds']);
    Route::post('/advertise/link/store', [\App\Http\Controllers\Admin\LinkController::class, 'storeLink']);
    Route::post('/advertise/link/update-status', [\App\Http\Controllers\Admin\LinkController::class, 'updateStatus']);

    Route::get('/withdrawals/load/{status}', [\App\Http\Controllers\Admin\WithdrawController::class, 'fetchHistory']);
    Route::get('/withdrawals/load', [\App\Http\Controllers\Admin\WithdrawController::class, 'fetchUserHistory']);
    Route::get('/withdrawals', [\App\Http\Controllers\Admin\WithdrawController::class, 'index']);
    Route::post('/withdrawals/update-status', [\App\Http\Controllers\Admin\WithdrawController::class, 'updateStatus']);
    
    Route::get('/deposits/load/{status}', [\App\Http\Controllers\Admin\DepositController::class, 'fetchHistory']);  
    Route::get('/deposits/load', [\App\Http\Controllers\Admin\DepositController::class, 'fetchUserHistory']);  
    Route::get('/deposits', [\App\Http\Controllers\Admin\DepositController::class, 'index']);
    
    Route::get('/faucet-history/load/', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchFaucet']);  
    Route::get('/faucet-history/load/{uid}', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchFaucet']); 
    Route::get('/faucet-history', [\App\Http\Controllers\Admin\HistoryController::class, 'faucet']);
    
    Route::get('/link-history/load/', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchLink']);  
    Route::get('/link-history/load/{uid}', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchLink']); 
    Route::get('/link-history', [\App\Http\Controllers\Admin\HistoryController::class, 'link']);

    Route::get('/ptc-history/load/', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchPtc']);  
    Route::get('/ptc-history/load/{uid}', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchPtc']); 
    Route::get('/ptc-history', [\App\Http\Controllers\Admin\HistoryController::class, 'ptc']);

    Route::get('/contest-history/load/', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchContest']);  
    Route::get('/contest-history/load/{uid}', [\App\Http\Controllers\Admin\HistoryController::class, 'fetchContest']); 
    Route::get('/contest-history', [\App\Http\Controllers\Admin\HistoryController::class, 'contest']);

    Route::get('/offerwall/load/{status}', [\App\Http\Controllers\Admin\OfferwallController::class, 'fetchHistory']);  
    Route::get('/offerwall/load/{status}/{uid}', [\App\Http\Controllers\Admin\OfferwallController::class, 'fetchHistory']); 
    Route::get('/offerwall', [\App\Http\Controllers\Admin\OfferwallController::class, 'index']);
    Route::post('/offerwall/update-status', [\App\Http\Controllers\Admin\OfferwallController::class, 'updateStatus']);

    Route::get('/blog', [\App\Http\Controllers\Admin\PostController::class, 'index']);
    Route::get('/blog/add', [\App\Http\Controllers\Admin\PostController::class, 'create']);
    Route::get('/blog/load', [\App\Http\Controllers\Admin\PostController::class, 'load']);
    Route::get('/blog/edit/{id}', [\App\Http\Controllers\Admin\PostController::class, 'edit']);
    Route::put('/blog/update/{id}', [\App\Http\Controllers\Admin\PostController::class, 'update']);
    Route::post('/blog/upload-image', [\App\Http\Controllers\Admin\PostController::class, 'uploadFile']);
    Route::post('/blog/store', [\App\Http\Controllers\Admin\PostController::class, 'store']);
    Route::delete('/post/delete/{id}', [\App\Http\Controllers\Admin\PostController::class, 'delete']);
    
    Route::get('/pages', [\App\Http\Controllers\Admin\PageController::class, 'index']);
    Route::get('/page/add', [\App\Http\Controllers\Admin\PageController::class, 'create']);
    Route::get('/page/load', [\App\Http\Controllers\Admin\PageController::class, 'load']);
    Route::get('/page/edit/{id}', [\App\Http\Controllers\Admin\PageController::class, 'edit']);
    Route::put('/page/update/{id}', [\App\Http\Controllers\Admin\PageController::class, 'update']);
    Route::post('/page/upload-image', [\App\Http\Controllers\Admin\PageController::class, 'uploadFile']);
    Route::post('/page/store', [\App\Http\Controllers\Admin\PageController::class, 'store']);
    Route::delete('/page/delete/{id}', [\App\Http\Controllers\Admin\PageController::class, 'delete']);
});


