si-klinik/sk-klinik.my.id/app/Http/Controllers/Admin/PatientController.php

39 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Patient;
use BaconQrCode\Renderer\Image\SvgImageBackEnd;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
class PatientController extends Controller
{
public function print(Patient $patient)
{
$patient->load('user');
// Generate URL verifikasi (ganti dengan domain asli kamu nanti)
$url = route('verify.patient', $patient->nik);
$renderer = new ImageRenderer(
new RendererStyle(200, 0),
new SvgImageBackEnd()
);
$writer = new Writer($renderer);
// Sekarang QR Code berisi LINK, bukan cuma angka NIK
$qrcode = $writer->writeString($url);
return view('admin.patients.print', compact('patient', 'qrcode'));
}
public function verify($nik)
{
$patient = Patient::with('user')->where('nik', $nik)->firstOrFail();
return view('admin.patients.verify-status', compact('patient'));
}
}