<?php

namespace App\Http\Controllers;

use App\Models\Diagnosa;
use App\Models\DiagnosaDetail;
use Illuminate\Http\Request;

class DiagnosaController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $numtab = 1;
        $diagnosa = Diagnosa::with(['user', 'penyakit'])->get();
        return view('server-side.pages.manajemen-laporan.diagnosa.data', compact(['numtab', 'diagnosa']));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $diagnosaId = (new Diagnosa())->generateId();
        // return view('server-side.pages.manajemen-laporan..', compact('diagnosaId'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Diagnosa  $diagnosa
     * @return \Illuminate\Http\Response
     */
    public function show(Diagnosa $diagnosa)
    {
        $numtab = 1;
        $detail = DiagnosaDetail::with(['gejala'])->where('diagnosaId', $diagnosa->diagnosaId)->get();
        return view('server-side.pages.manajemen-laporan.diagnosa.detail', compact(['numtab', 'diagnosa', 'detail']));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Diagnosa  $diagnosa
     * @return \Illuminate\Http\Response
     */
    public function edit(Diagnosa $diagnosa)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Diagnosa  $diagnosa
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Diagnosa $diagnosa)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Diagnosa  $diagnosa
     * @return \Illuminate\Http\Response
     */
    public function destroy(Diagnosa $diagnosa)
    {
        $diagnosa->delete();
        return redirect()->route('diagnosa.index')->with('message', 'Berhasil menghapus data diagnosa yang dipilih');
    }
}
