<?php

use App\Http\Controllers\AdminController;
use App\Http\Controllers\ApresiasiController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\InformasiController;
use App\Http\Controllers\PanduanController;
use App\Http\Controllers\PelaporanController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\RiwayatLaporanController;
use App\Http\Controllers\SessionController;
use App\Http\Controllers\TindakanController;
use App\Http\Controllers\UsersController;
use App\Models\RiwayatLaporan;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" midRequest $requesteware group. Make something great!
|
*/

Route::group(['middleware' => 'auth'], function ()
{

});
Route::middleware(['auth', 'check.role:admin'])->group(function () {
    // Rute yang hanya dapat diakses oleh admin
    #Dashboard
    Route::get('dashboards', [DashboardController::class, 'index'])->name('admin.dashboards');

    #User
    Route::get('/user', [UsersController::class, 'index'])->name('user.index');
    Route::get('/user/create', [UsersController::class, 'create'])->name('user.create');
    Route::post('/user/create', [UsersController::class, 'store'])->name('user.store');
    Route::get('/user/{id}/edit', [UsersController::class, 'edit'])->name('user.edit');
    Route::put('/user/{id}/edit', [UsersController::class, 'update'])->name('user.update');
    Route::get('/user/{id}', [UsersController::class, 'destroy'])->name('user.destroy');

    #Tindakan
    Route::get('/tindakan', [TindakanController::class, 'index'])->name('tindakan.index');
    Route::get('/tindakan/{id}/edit', [TindakanController::class, 'edit'])->name('tindakan.edit');
    Route::get('/tindakan/{id}/show', [TindakanController::class, 'show'])->name('tindakan.show');
    Route::put('/tindakan/{id}/edit', [TindakanController::class, 'update'])->name('tindakan.update');
    Route::get('/tindakan/{id}', [TindakanController::class, 'destroy'])->name('tindakan.destroy');

    #Informasi
    Route::get('/informasi', [InformasiController::class, 'adminIndex'])->name('informasi.adminIndex');
    Route::get('/informasi/create', [InformasiController::class, 'adminCreate'])->name('informasi.adminCreate');
    Route::post('/informasi/create', [InformasiController::class, 'adminStore'])->name('informasi.adminStore');
    Route::get('/informasi/{id}/edit', [InformasiController::class, 'adminEdit'])->name('informasi.adminEdit');
    Route::put('/informasi/{id}/edit', [InformasiController::class, 'adminUpdate'])->name('informasi.adminUpdate');
    Route::get('/informasi/{id}', [InformasiController::class, 'adminDestroy'])->name('informasi.adminDestroy');

    #Apresiasi
    Route::get('/apresiasi-system', [ApresiasiController::class, 'adminIndex'])->name('apresiasi.adminIndex');
    Route::get('/apresiasi-system/{id}', [ApresiasiController::class, 'adminDestroy'])->name('apresiasi.adminDestroy');
    Route::get('/apresiasi-system/{id}/show', [ApresiasiController::class, 'adminShow'])->name('apresiasi.adminShow');
});

Route::middleware(['auth', 'check.role:user'])->group(function () {
    // Rute yang hanya dapat diakses oleh user biasa
    #Dashboard
    Route::get('/dashboard', [AdminController::class, 'index'])->name('users.dashboard');

    #Pelaporan
    Route::get('/pelaporan', [PelaporanController::class, 'index'])->name('pelaporan.index');
    Route::get('/pelaporan/create', [PelaporanController::class, 'create'])->name('pelaporan.create');
    Route::post('/pelaporan/create', [PelaporanController::class, 'store'])->name('pelaporan.store');
    Route::get('/pelaporan/{id}/edit', [PelaporanController::class, 'edit'])->name('pelaporan.edit');
    Route::put('/pelaporan/{id}/edit', [PelaporanController::class, 'update'])->name('pelaporan.update');
    Route::get('/pelaporan/{id}', [PelaporanController::class, 'destroy'])->name('pelaporan.destroy');

    #Informasi
    Route::get('/informasi-system', [InformasiController::class, 'userIndex'])->name('informasi.userIndex');
    Route::get('/informasi-system/{id}/show', [InformasiController::class, 'userShow'])->name('informasi.userShow');

    #Apresiasi
    Route::get('/apresiasi', [ApresiasiController::class, 'userIndex'])->name('apresiasi.userIndex');
    Route::get('/apresiasi/create', [ApresiasiController::class, 'userCreate'])->name('apresiasi.userCreate');
    Route::post('/apresiasi/create', [ApresiasiController::class, 'userStore'])->name('apresiasi.userStore');
    Route::get('/apresiasi/{id}/edit', [ApresiasiController::class, 'userEdit'])->name('apresiasi.userEdit');
    Route::get('/apresiasi/{id}/show', [ApresiasiController::class, 'userShow'])->name('apresiasi.userShow');
    Route::put('/apresiasi/{id}/edit', [ApresiasiController::class, 'userUpdate'])->name('apresiasi.userUpdate');
    Route::get('/apresiasi/{id}', [ApresiasiController::class, 'userDestroy'])->name('apresiasi.userDestroy');


});

#Riwayat Pelaporan
Route::get('/riwayat-pelaporan', [RiwayatLaporanController::class, 'index'])->name('riwayat.index');
Route::get('/riwayat-pelaporan/cetak', [RiwayatLaporanController::class, 'cetak'])->name('riwayat.cetak');

#Panduan
Route::get('/panduan', [PanduanController::class, 'index'])->name('panduan.index');

#Profile
Route::get('/profile', [ProfileController::class, 'index'])->name('profile.index');
Route::put('/profile', [ProfileController::class, 'update'])->name('profile.update');

#Sesion
Route::get('/', [SessionController::class, 'index'])->name('index.login');
Route::post('/', [SessionController::class, 'login'])->name('login');
Route::get('/registrasi', [SessionController::class, 'showRegistrationForm'])->name('register');
Route::post('/registrasi', [SessionController::class, 'signup'])->name('signup');
Route::get('/logout', [SessionController::class, 'logout'])->name('logout');
Route::get('/forgot-password', [SessionController::class, 'forgot'])->name('forgot');
Route::post('/forgot-password', [SessionController::class, 'sendResetLink'])->name('sendResetLink');
Route::get('/reset/{token}', [SessionController::class, 'showResetForm'])->name('password.reset');
Route::post('/reset/{token}', [SessionController::class, 'resetPassword'])->name('reset.password');



