Laravel 存储、损坏或未全部保存在数据库中
Laravel Store , corrupted or not all are saved on database
public function patient_aprrovedischarge(Request $request, $id)
{
//get patient details
$patientDischarge = DischargedPatients::where('id', '=', $id)->first();
//find patient update to DISCHARGE pending
$updatepatient = Patients::find($patientDischarge->patient_id);
$updatepatient->user_currently_at = 'DISCHARGED';
// //update discharge details
$dischargepatient = DischargedPatients::find($id);
$dischargepatient->status = 'approved';
$dischargepatient->discharged_by = auth()->user()->id;
$dischargepatient->discharged_date = date('Y-m-d H:i:s');
// //save remarks
$dischargeRemarks = new Remarks();
$dischargeRemarks->remarks_detail = 'Discharged Aprroved';
$dischargeRemarks->remarks_from = auth()->user()->id;
$dischargeRemarks->user_from_type = 'MO';
$dischargeRemarks->patient_id = $patientDischarge->patient_id;
$updatepatient->save();
$dischargepatient->save();
$dischargeRemarks->save();
return redirect('/medical/discharged')->with('success', 'Patient is now discharged!');
}
抱歉,我对堆栈溢出不太满意,我的问题是并非所有这 3 个保存都在数据库中。它已经上传到主机上,也许任何人都可以解释为什么,我认为它与互联网有问题,因为有时它会断开连接
您正在尝试保存同一条记录两次,基本上$patientDischarge
和$dischargepatient
是相同的记录。
public function patient_aprrovedischarge(Request $request, $id)
{
//get patient details
$patientDischarge = DischargedPatients::findOrFail($id);
$patientDischarge->status = 'approved';
$patientDischarge->discharged_by = auth()->id();
$patientDischarge->discharged_date = date('Y-m-d H:i:s');
$patientDischarge->save();
//find patient update to DISCHARGE pending
$updatepatient = Patients::findOrFail($patientDischarge->patient_id);
$updatepatient->update([
'user_currently_at' => 'DISCHARGED',
]);
Remarks::create([
'remarks_detail' => 'Discharged Aprroved',
'remarks_from' => auth()->id(),
'user_from_type' => 'MO',
'patient_id' => $patientDischarge->patient_id,
])
return redirect('/medical/discharged')->with('success', 'Patient is now discharged!');
}
public function patient_aprrovedischarge(Request $request, $id)
{
//get patient details
$patientDischarge = DischargedPatients::where('id', '=', $id)->first();
//find patient update to DISCHARGE pending
$updatepatient = Patients::find($patientDischarge->patient_id);
$updatepatient->user_currently_at = 'DISCHARGED';
// //update discharge details
$dischargepatient = DischargedPatients::find($id);
$dischargepatient->status = 'approved';
$dischargepatient->discharged_by = auth()->user()->id;
$dischargepatient->discharged_date = date('Y-m-d H:i:s');
// //save remarks
$dischargeRemarks = new Remarks();
$dischargeRemarks->remarks_detail = 'Discharged Aprroved';
$dischargeRemarks->remarks_from = auth()->user()->id;
$dischargeRemarks->user_from_type = 'MO';
$dischargeRemarks->patient_id = $patientDischarge->patient_id;
$updatepatient->save();
$dischargepatient->save();
$dischargeRemarks->save();
return redirect('/medical/discharged')->with('success', 'Patient is now discharged!');
}
抱歉,我对堆栈溢出不太满意,我的问题是并非所有这 3 个保存都在数据库中。它已经上传到主机上,也许任何人都可以解释为什么,我认为它与互联网有问题,因为有时它会断开连接
您正在尝试保存同一条记录两次,基本上$patientDischarge
和$dischargepatient
是相同的记录。
public function patient_aprrovedischarge(Request $request, $id)
{
//get patient details
$patientDischarge = DischargedPatients::findOrFail($id);
$patientDischarge->status = 'approved';
$patientDischarge->discharged_by = auth()->id();
$patientDischarge->discharged_date = date('Y-m-d H:i:s');
$patientDischarge->save();
//find patient update to DISCHARGE pending
$updatepatient = Patients::findOrFail($patientDischarge->patient_id);
$updatepatient->update([
'user_currently_at' => 'DISCHARGED',
]);
Remarks::create([
'remarks_detail' => 'Discharged Aprroved',
'remarks_from' => auth()->id(),
'user_from_type' => 'MO',
'patient_id' => $patientDischarge->patient_id,
])
return redirect('/medical/discharged')->with('success', 'Patient is now discharged!');
}