Im using filter_Var for sanitizing string to my input values
public function appointmentStore(Request $request) {
$request->validate([
'appointmentDate' => 'required',
'appointmentTime' => 'required',
'services' => 'required',
'Others' => 'nullable',
'appointmentDescription' => 'required',
],
[
'appointmentDate.required' => 'Appointment Date is required',
'appointmentTime.required' => 'Appointment Time is required',
'services.required' => 'services is required',
'Others.required' => 'Other is required ',
'appointmentDescription.required' => 'appointmentDescription is required',
]);
$appointment = new appointment();
$appointment->appointmentDate = filter_var($request->appointmentDate, FILTER_SANITIZE_STRING);
$appointment->appointmentTime = filter_var($request->appointmentTime, FILTER_SANITIZE_STRING);
$appointment->Others = filter_var($request->Others, FILTER_SANITIZE_STRING);
$appointment->appointmentDescription = filter_var($request->appointmentDescription, FILTER_SANITIZE_STRING);
$appointment->services = filter_var($request->services, FILTER_SANITIZE_STRING);
$appointment->save();
return redirect()->route('setAppointment.show')->with('success', 'Appointment Saved');
}
Top comments (0)