<?php

use App\Http\Controllers\CodeController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\QrCodeController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Route::get('/', function () {
//     return Inertia::render('Welcome', [
//         'canLogin' => Route::has('login'),
//         'canRegister' => false, //Route::has('register'),
//         'laravelVersion' => Application::VERSION,
//         'phpVersion' => PHP_VERSION,
//     ]);
// });

Route::get('/', function () {
    return redirect()->route('qrgenerator');
})->middleware(['auth', 'verified'])->name('dashboard');

Route::get('/qr-generate', [QrCodeController::class, 'issue'])->name('qrissue');
Route::post('/qr-generate', [QrCodeController::class, 'storeNic'])->name('storeNic');


Route::prefix('admin')->middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');

    Route::get('/', [QrCodeController::class, 'index'])->name('qrgenerator');
    Route::get('/scan', [QrCodeController::class, 'scan'])->name('qr.scan');
    Route::get('/scan/{code}', [QrCodeController::class, 'getCodeData'])->name('qr.getCodeData');
    
    Route::get('/hash', CodeController::class)->name('hashgenerator');
    Route::post('/claim', [QrCodeController::class, 'claim'])->name('qr.claim');


});

require __DIR__.'/auth.php';
