<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\EventRegistrationController;

Route::redirect('/', '/registration');

Route::prefix('registration')->name('registration.')->group(function () {
    // Show registration form
    Route::get('/', [EventRegistrationController::class, 'create'])
        ->name('create');

    // Store registration
    Route::post('/', [EventRegistrationController::class, 'store'])
        ->name('store');

    // Show success page
    Route::get('/success', [EventRegistrationController::class, 'success'])
        ->name('success');

    // Show result page
    Route::get('/result', [EventRegistrationController::class, 'result'])
        ->name('result');
});

// Payment routes
Route::prefix('payment')->name('payment.')->group(function () {
    // Redirect to PayU gateway
    Route::get('/redirect/{regId}', [EventRegistrationController::class, 'paymentRedirect'])
        ->name('redirect');

    // PayU callbacks (POST requests)
    Route::post('/success', [EventRegistrationController::class, 'paymentSuccess'])
        ->withoutMiddleware(['VerifyCsrfToken'])
        ->name('success');

    Route::post('/failure', [EventRegistrationController::class, 'paymentFailure'])
        ->withoutMiddleware(['VerifyCsrfToken'])
        ->name('failure');
});
