<?php

use App\Http\Controllers\DashboardController;
use App\Http\Controllers\KriteriaController;
use App\Http\Controllers\MakananController;
use App\Http\Controllers\PasienController;
use App\Http\Controllers\PerhitunganController;
use App\Http\Controllers\ProfileController;
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" middleware group. Make something great!
|
 */

Route::get('/', function () {
    return view('auth.login');
});

//home
Route::group(['middleware' => ['verified', 'auth']], function () {
    Route::get('/home', [DashboardController::class, 'index'])->name('home');
});

//Data Pasien
Route::group(['middleware' => ['verified', 'auth']], function () {
    Route::get('/home/datapasien', [PasienController::class, 'index'])->name('pasien.index');
    Route::get('/home/datapasien/create', [PasienController::class, 'create'])->name('pasien.create');
    Route::post('/home/datapasien/store', [PasienController::class, 'store'])->name('pasien.store');
    Route::get('/home/datapasien/edit/{id}', [PasienController::class, 'edit'])->name('pasien.edit');
    Route::post('/home/datapasien/update/{id}', [PasienController::class, 'update'])->name('pasien.update');
    Route::get('/home/datapasien/show/{id}', [PasienController::class, 'show'])->name('pasien.show');
    Route::get('/home/datapasien/destroy/{id}', [PasienController::class, 'destroy'])->name('pasien.destroy');
});

//Makanan
Route::group(['middleware' => ['verified', 'auth']], function () {
    Route::get('/home/makanan', [MakananController::class, 'index'])->name('makanan.index');
    Route::get('/home/makanan/create', [MakananController::class, 'create'])->name('makanan.create');
    Route::post('/home/makanan/store', [MakananController::class, 'store'])->name('makanan.store');
    Route::get('/home/makanan/edit/{id}', [MakananController::class, 'edit'])->name('makanan.edit');
    Route::post('/home/makanan/update/{id}', [MakananController::class, 'update'])->name('makanan.update');
    Route::get('/home/makanan/show/{id}', [MakananController::class, 'show'])->name('makanan.show');
    Route::get('/home/makanan/destroy/{id}', [MakananController::class, 'destroy'])->name('makanan.destroy');
    Route::post('/home/makanan/store/detailmakanan/{idMakanan}', [MakananController::class, 'storeDetailMakanan'])->name('makanan.tambahdetailmakanan');
    Route::get('/home/makanan/destroy/detailmakanan/{id}/{idMakanan}', [MakananController::class, 'destroyDetailMakanan'])->name('makanan.destroydetailmakanan');
    Route::post('/home/makanan/update/detailmakanan/{id}/{idMakanan}', [MakananController::class, 'updateDetailMakanan'])->name('makanan.updatedetailmakanan');
});

//kriteria
Route::group(['middleware' => ['verified', 'auth']], function () {
    Route::get('/home/kriteria', [KriteriaController::class, 'index'])->name('kriteria.index');
    Route::get('/home/kriteria/create', [KriteriaController::class, 'create'])->name('kriteria.create');
    Route::post('/home/kriteria/store', [KriteriaController::class, 'store'])->name('kriteria.store');
    Route::get('/home/kriteria/edit/{id}', [KriteriaController::class, 'edit'])->name('kriteria.edit');
    Route::post('/home/kriteria/update/{id}', [KriteriaController::class, 'update'])->name('kriteria.update');
    Route::get('/home/kriteria/destroy/{id}', [KriteriaController::class, 'destroy'])->name('kriteria.destroy');
});

Route::get('/home/perhitungan/{id}', [PerhitunganController::class, 'index'])->name('perhitungan.index');
Route::get('/home/perhitungan/cetak/{id}/{pasien}', [PerhitunganController::class, 'cetak'])->name('cetak.index');

Route::group(['middleware' => ['verified', 'auth']], function () {
    Route::get('/home/profile/{id}', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::post('/home/profile/{id}', [ProfileController::class, 'update'])->name('profile.update');
});

require __DIR__ . '/auth.php';
