<?php

use App\Http\Controllers\Admin;
use App\Http\Controllers\WelcomeController;
use App\Jobs\RunGameJob;
use App\Models\Game;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

/* --Web Routes--*/

Auth::routes(['register' => false]);
Route::get('/', [WelcomeController::class, 'index']);

/*----------------Admin Routes---------------------*/
Route::middleware('can:admin')->group(function () {

    Route::get('/dashboard', [Admin\DashboardController::class, 'index'])
        ->name('dashboard');
    Route::get('/start-game', [Admin\GameJobController::class, 'index'])
        ->name('start-game');
    Route::resource('/agents', Admin\AgentController::class)->except('show');
    Route::post('/agents/{agent}/toggle-block', [Admin\AgentController::class, 'toggleBlock']);
    Route::get('/agent-balance-update/{agent}', [Admin\AgentBalanceController::class, 'index'])
        ->name('agent-balance.index');
    Route::post('/agent-balance-update/{agent}', [Admin\AgentBalanceController::class, 'update'])
        ->name('agent-balance.update');

    Route::get('/games', [Admin\GameController::class, 'index'])->name('games.index');
    Route::post('/games/{game}/set-manual-result', [Admin\GameController::class, 'setManualResult'])
        ->name('games.setManualResult');
    Route::get('games/current-running', [Admin\GameController::class, 'currentRunning'])
        ->name('games.current-running');

    Route::get('/bettings', [Admin\BettingController::class, 'index'])
        ->name('bettings.index');

    Route::get('/transactions', [Admin\TransactionController::class, 'index'])
        ->name('transactions.index');

    Route::resource('/settings', Admin\SettingController::class)
        ->only(['index', 'store']);

    Route::post('/settings/change-password', [Admin\SettingController::class, 'changePassword'])
        ->name('settings.change-password');
});
