I have 2 tables. Patient table and reservation table.
Patient table:
- ID
- name
- medical record number (norekmed)
Table of reservations
- ID
- idpatient
- idroom
How do I check patient data already or not if I make a reservation?
Checking is by comparing between a reservation form field with norekmed in the patient table.
If patient data already exists, we can make a reservation. And if there is no patient data, we cannot make a reservation.
If it turns out this is not good, and there is a better method, I accept that.
Reservation controller (store)
$this->validate($request,
[
'idpatient' => 'required|unique:reservation,idpatient',
'idroom' => 'required',
]);
Patient::where(function($query) {
$query->has('id')
->orHas('norekmed');
})->find(1);
$reservasi = new Reservasi();
$reservasi->idpatient = $request->idpatient;
$reservasi->idroom = $request->idroom;
$reservasi->save();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire