<?php

use App\Http\Controllers\DashboardController;
use App\Http\Controllers\DataSoalController;
use App\Http\Controllers\HasilTesController;
use App\Http\Controllers\LandingController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UsersController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return redirect('/beranda');
});

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

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::resource('beranda', LandingController::class);
Route::middleware(['auth', 'role.auth'])->group(function() {
    Route::resource('dashboard', DashboardController::class);
    Route::resource('users', UsersController::class);
        Route::get('users/fetch/data', [UsersController::class, 'getData'])->name('users.fetchData');
    Route::resource('soal', DataSoalController::class);
        Route::get('soal/fetch/data', [DataSoalController::class, 'getData'])->name('soal.fetchData');
    Route::resource('hasil_tes', HasilTesController::class);
});

require __DIR__.'/auth.php';
