<?php

use App\Http\Controllers\UserController;
use App\Http\Controllers\StatementController;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;

Route::get('/', function () {
    if (Auth::check()) {
        return redirect(route('homepage'));
    }
    return redirect(route('login'));
})->name('form');

Route::get('/login', function (): View {
    return view('login');
})->name('login');

Route::get('/homepage', function (): View {
    if(Auth::user()){
        return view('homepage');
    }
    return view('login');
})->name('homepage');

Route::post('/reg', [UserController::class, 'reg'])->name('reg');
Route::post('/log', [UserController::class,'log'])->name('log');


Route::middleware('auth')->group(function () {
    Route::get('/out', [UserController::class, 'out'])->name('out');
    // Route::get('/homepage', function (): View {
    //     return view('homepage');
    // })->name('homepage');
    Route::post('/addstate', [StatementController::class, 'addstate'])->name('addstate');
    Route::get('/homepage', [StatementController::class, 'states'])->name('homepage');

    Route::get('/true/{id}', [StatementController::class, 'statestatus'])->name('true');
    Route::get('/false/{id}', [StatementController::class, 'statestatus'])->name('false');
}); 





    


