<?php

use App\Http\Controllers\BobotController;
use App\Http\Controllers\ClientController;
use App\Http\Controllers\DiagnosaController;
use App\Http\Controllers\GejalaController;
use App\Http\Controllers\InformasiController;
use App\Http\Controllers\PenyakitController;
use App\Http\Controllers\RuleController;
use App\Http\Controllers\ServerController;
use App\Models\Informasi;
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 landing pages //
Route::get('/', function () {
    $informasi = Informasi::latest()->limit(3)->get();
    return view('client-side.welcome', compact('informasi'));
})->name('land.beranda');

// ! Artikel Route //
Route::get('blog-informasi', [ClientController::class, 'BlogInformasi'])->name('artikel.list');
Route::get('blog-informasi/{slug}', [ClientController::class, 'DetailBlogInformasi'])->name('artikel.detail');

// ! Kontak Route //
Route::get('kontak-kami', [ClientController::class, 'KontakKami'])->name('kontak.index');
Route::post('kontak-kami', [ClientController::class, 'KontakStore'])->name('kontak.store');

// ! Konsultasi Route //
Route::get('solusi-perawatan', [ClientController::class, 'SolusiPerawatan'])->name('solusi.perawatan');

// ? Route middleware auth verified //
Route::middleware(['auth', 'verified'])->group(function () {
    // ! Client Side Route //
    Route::get('diagnosa-penyakit', [ClientController::class, 'DiagnosaPenyakit'])->name('diagnosa.penyakit');
    Route::post('diagnosa-penyakit', [ClientController::class, 'HasilDiagnosa'])->name('diagnosa.get');
    Route::post('diagnosa-penyakit-store', [ClientController::class, 'DiagnosaStore'])->name('diagnosa.post');
    Route::get('riwayat-diagnosa/{userId}', [ClientController::class, 'RiwayatDiagnosa'])->name('riwayat.diagnosa');
    Route::get('detail-diagnosa/{diagnosaId}', [ClientController::class, 'DetailDiagnosa'])->name('detail.diagnosa');

    // ! Server Side Route //
    Route::get('dashboard', [ServerController::class, 'Dashboard'])->name('dashboard');

    // ? Route Manajemen Pengguna //
    Route::get('registrasi-pengguna', [ServerController::class, 'RegistrasiPengguna'])->name('registrasi.pengguna');
    Route::post('registrasi-pengguna', [ServerController::class, 'RegistrasiStore'])->name('registrasi.store');
    Route::delete('hapus-pengguna/{penggunaId}', [ServerController::class, 'HapusPengguna'])->name('hapus.pengguna');
    Route::get('data-pengguna', [ServerController::class, 'DataPengguna'])->name('data.pengguna');

    // ? Route Manajemen Data //
    Route::resource('bobot', BobotController::class);
    Route::resource('penyakit', PenyakitController::class);
    Route::resource('gejala', GejalaController::class);
    Route::resource('rule', RuleController::class);
    Route::delete('rule/delete-by-penyakit/{penyakitId}', [RuleController::class, 'destroyByPenyakit'])->name('rule.destroyByPenyakit');

    // ? Route Manajemen Laporan //
    Route::resource('diagnosa', DiagnosaController::class);
    Route::get('pesan-pengguna', [ServerController::class, 'PesanPengguna'])->name('pesan.pengguna');
    Route::delete('pesan-pengguna/{id}', [ServerController::class, 'HapusPesan'])->name('pesan.destroy');

    // ? Route Manajemen Konten //
    Route::resource('informasi', InformasiController::class);
});

require __DIR__.'/auth.php';
