<?php

use App\Http\Controllers\ProfileController;
use App\Http\Controllers\QrController; 
use App\Http\Controllers\attendancecontroller;
use Illuminate\Support\Facades\Route;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Writer\PngWriter;



Route::get('/', function () {
    return view('welcome');
});

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

Route::get('/qrcode', function () {

     $result = Builder::create()
        ->writer(new PngWriter())
        ->data('https://conference-system.test/register')
        ->size(300)
        ->margin(10)
        ->logoPath(public_path('images/fmoh.png')) // ضع شعارك هنا
        ->logoResizeToWidth(100) // حجم الشعار داخل QR
        ->logoResizeToHeight(100)
        ->build();
    return response($result->getString(), 200)
        ->header('Content-Type', $result->getMimeType());
});

Route::get('/qr-save', [App\Http\Controllers\QrController::class, 'generateQrWithLogo']);


Route::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::prefix('attendance/')->as('attendance.')->group(function () {
        Route::get('index', [attendancecontroller::class, 'index'])->name('index');
        Route::post('store', [attendancecontroller::class, 'store'])->name('store');

        Route::get('data', [attendancecontroller::class, 'getData'])->name('data');

        Route::get('card/{guest_id}', [attendancecontroller::class, 'getcard'])->name('card');

       
    });

});

require __DIR__.'/auth.php';
