<?php
namespace App\Http\Controllers\Patient;
use App\Http\Controllers\Controller;
use App\Models\MedicalRecord;

class RecordController extends Controller
{
    public function index()
    {
        $records = MedicalRecord::with('doctor.user')
            ->where('patient_id', session('patient_id'))
            ->where('is_confidential', false)
            ->latest('visit_date')
            ->paginate(10);

        return view('patient.records.index', compact('records'));
    }

    public function show($id)
    {
        $record = MedicalRecord::with('doctor.user')
            ->where('patient_id', session('patient_id'))
            ->where('is_confidential', false)
            ->findOrFail($id);

        return view('patient.records.show', compact('record'));
    }
}
