after validation not going to try or catch so can't store value
What I have tried:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\Alertandconsents;
use Illuminate\Http\Request;
class AlertandconsentController extends Controller
{
public function index()
{
return view('patients.edit');
}
public function store(Request $request)
{
$validated = $request->validate([
'patient_id' => 'required',
'bpresure' => 'required',
'h_align' => 'required',
'rf' => 'required',
'acb_problem' => 'required',
'tubercalosis' => 'required',
'sb_problem' => 'required',
'kidney_d' => 'required',
'smoke' => 'required',
'hv_implant' => 'required',
'dt' => 'required',
'previous_il' => 'required',
'date' => 'required',
'u_medical_c' => 'required',
'dmt' => 'required',
'p_or_f' => 'required',
'alergies' => 'required',
'diabetics' => 'required',
'thyroid_p' => 'required',
'bb_disorder' => 'required',
'epilepsy' => 'required',
'hepatitis' => 'required',
'hiv_aids' => 'required',
'remark' => 'required'
]);
try {
dd(3);
$alertandconsents = new Alertandconsents;
$alertandconsents->patient_id = $validated['patient_id'];
$alertandconsents->bpresure= $validated['bpresure'];
$alertandconsents->h_align= $validated['h_align'];
$alertandconsents->rf= $validated['rf'];
$alertandconsents->acb_problem= $validated['acb_problem'];
$alertandconsents->tubercalosis= $validated['tubercalosis'];
$alertandconsents->sb_problem= $validated['sb_problem'];
$alertandconsents->kidney_d= $validated['kidney_d'];
$alertandconsents->smoke= $validated['smoke'];
$alertandconsents->hv_implant= $validated['hv_implant'];
$alertandconsents->dt= $validated['dt'];
$alertandconsents->previous_il= $validated['previous_il'];
$alertandconsents->date= $validated['date'];
$alertandconsents->u_medical_c= $validated['u_medical_c'];
$alertandconsents->dmt= $validated['dmt'];
$alertandconsents->p_or_f= $validated['p_or_f'];
$alertandconsents->alergies= $validated['alergies'];
$alertandconsents->diabetics= $validated['diabetics'];
$alertandconsents->thyroid_p= $validated['thyroid_p'];
$alertandconsents->bb_disorder= $validated['bb_disorder'];
$alertandconsents->epilepsy = $validated['epilepsy'];
$alertandconsents->hepatitis = $validated['hepatitis'];
$alertandconsents->hiv_aids = $validated['hiv_aids'];
$alertandconsents->remark =$validated['remark'] ;
$alertandconsents->save();
return redirect()->route('patient.edit',['patientsId' => $request->patient_id])->with('success', 'Alert and consents are successfully added!.');
} catch (\Exception $e) {
dd(1);
report($e);
return redirect()->back()->with('error', 'Failed to add alert and consents! Please try again.');
}
}
}