<?php

use App\Http\Controllers\Admin\NidServerlistController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\BkashController;
use App\Http\Controllers\BKashPaymentController;
use App\Http\Controllers\RechargeController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\NidServerCopyController;



Route::get('/', function () {
    return view('welcome'); // resources/views/welcome.blade.php লোড করবে
});



Route::middleware('guest')->group(function () {

    Route::get('/login', [
        AuthController::class,
        'showLogin'
    ])->name('login');

    Route::post('/login', [
        AuthController::class,
        'login'
    ])->name('login.submit');

    // Route::get('/register', [
    //     AuthController::class,
    //     'showRegister'
    // ])->name('register');

    // Route::post('/register', [
    //     AuthController::class,
    //     'register'
    // ])->name('register.submit');

});

Route::post('/logout', [
    AuthController::class,
    'logout'
])->middleware('auth')->name('logout');





// Admin Routes (শুধুমাত্র Admin ঢুকতে পারবে)
Route::middleware(['auth', 'is_admin'])->prefix('admin')->group(function () {
    Route::get('/dashboard', [AdminController::class, 'dashboard'])->name('admin.dashboard');
    Route::get('/users', [AdminController::class, 'manageUsers']);
});

// User Routes (শুধুমাত্র সাধারণ User ঢুকতে পারবে)
Route::middleware(['auth', 'is_user'])->prefix('user')->group(function () {
    Route::get('/dashboard', [UserController::class, 'dashboard'])->name('user.dashboard');
    Route::get('/profile', [UserController::class, 'profile']);

    Route::get('/recharge', [RechargeController::class, 'index'])->name('recharge.index');
    Route::post('/recharge', [RechargeController::class, 'store'])->name('recharge.store');


    


});


Route::middleware(['auth', 'is_admin'])->prefix('admin')->group(function () {
    Route::get('/recharges', [RechargeController::class, 'recharges'])->name('admin.recharges.index');
    Route::post('/recharges/{id}/approve', [RechargeController::class, 'approveRecharge'])->name('admin.recharges.approve');
    Route::post('/recharges/{id}/reject', [RechargeController::class, 'rejectRecharge'])->name('admin.recharges.reject');


    Route::get('nid/server/request',[NidServerlistController::class,'index'])->name('nid.server.index');
    Route::post('/nid-requests/{id}/update-status', [NidServerlistController::class, 'updateStatus'])->name('nid.updateStatus');
});






Route::middleware(['auth'])->group(function () {
    Route::get('/bkash/payment', [BKashPaymentController::class, 'createPayment'])->name('bkash.create');
    Route::get('/bkash/callback', [BKashPaymentController::class, 'callback'])->name('bkash.callback');
});


Route::get('/bkash/pay', [
    BkashController::class,
    'pay'
])->name('bkash.pay');

Route::get('/bkash/callback', [
    BkashController::class,
    'callback'
])->name('bkash.callback');




Route::get('/nid-server-copy', [NidServerCopyController::class, 'index'])->name('nid.index');
Route::post('/nid-server-copy', [NidServerCopyController::class, 'store'])->name('nid.store');