<?php

use App\Http\Controllers\AuthController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\KategoriController;
use App\Http\Controllers\MekanikController;
use App\Http\Controllers\SubUnitController;
use App\Http\Controllers\UnitController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;

Route::controller(AuthController::class)->group(function () {
    Route::get('', 'login')->name('login');
    Route::get('logout', 'logout')->name('logout');

    Route::post('post-login', 'post_login')->name('post_login');
});

Route::group(['middleware' => ['auth']], function () {
    Route::controller(DashboardController::class)->group(function () {
        Route::get('dashboard', 'index')->name('dashboard');
    });
    Route::controller(UserController::class)->group(function () {
        Route::get('pengguna', 'index')->name('pengguna');

        Route::post('pengguna/add', 'add')->name('pengguna.add');
        Route::post('pengguna/update/{id}', 'update')->name('pengguna.update');

        Route::delete('pengguna/delete/{id}', 'delete')->name('pengguna.delete');
    });
    Route::controller(MekanikController::class)->group(function () {
        Route::get('mekanik', 'index')->name('mekanik');

        Route::post('mekanik/add', 'add')->name('mekanik.add');
        Route::post('mekanik/update/{id}', 'update')->name('mekanik.update');

        Route::delete('mekanik/delete/{id}', 'delete')->name('mekanik.delete');
    });
    Route::controller(KategoriController::class)->group(function () {
        Route::get('kategori', 'index')->name('kategori');

        Route::post('kategori/add', 'add')->name('kategori.add');
        Route::post('kategori/update/{id}', 'update')->name('kategori.update');

        Route::delete('kategori/delete/{id}', 'delete')->name('kategori.delete');
    });
    Route::controller(UnitController::class)->group(function () {
        Route::get('unit', 'index')->name('unit');

        Route::post('unit/add', 'add')->name('unit.add');
        Route::post('unit/update/{id}', 'update')->name('unit.update');

        Route::delete('unit/delete/{id}', 'delete')->name('unit.delete');
    });
    Route::controller(SubUnitController::class)->group(function () {
        Route::get('subunit', 'index')->name('subunit');

        Route::post('subunit/add', 'add')->name('subunit.add');
        Route::post('subunit/update/{id}', 'update')->name('subunit.update');

        Route::delete('subunit/delete/{id}', 'delete')->name('subunit.delete');
    });
});
