I have an online appointment form in my Laravel application with some filed Select Doctor and datepicker.
Suppose doctor A will be available in clinic at Saturday, Monday and Wednesday. And doctor B will be available at Sunday, Tuesday, Thursday. So while any patient choose doctor A from the Select Doctor field, all the dates with Saturday, Monday and Wednesday will be activated in the datepicker calendar and other dates will be deactivated.
I have already deactivated some selected dates of datepicker calendar. But can't disable date for selected days in datepicker.
html
<input class="form-control" id="appointment_datepicker" name="appointment_datepicker" type="text" placeholder="Select Date" value="{{ $user->appointment_datepicker or old('appointment_datepicker') }}">
ajax
$.ajax({
url:"{{ url('/filter_available_date') }}",
type: 'GET',
data: {_token :token, branch_id_appointment : branch_id_appointment, doctor_id_appointment : doctor_id_appointment},
success:function(msg){
$('#appointment_datepicker').datepicker('option', 'beforeShowDay', function(date){
var day = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ msg.indexOf(day) == -1 ] //here msg is the Array of selected Dates which are activated in the datepicker calendar
});
}
});
route
Route::get('/filter_available_date','frontendAppointmentController@filter_available_date');
controller
public function filter_available_date(Request $request)
{
$branch_id = $request->branch_id_appointment;
$doctor_id = $request->doctor_id_appointment;
$query = DB::table('service_doctors');
$query->select('doctor_id','inactive_dates_in_this_month');
if($branch_id != '0')
$query->where('branch_id','=', $branch_id);
if($doctor_id != NULL)
$query->where('doctor_id','=', $doctor_id);
$result_time = $query->get();
$result = [$result_time[0]->inactive_dates_in_this_month];
$final_result= explode(',',$result[0]);
return $final_result;
}
How to solve the issue ? Anybody Help Please ? Thanks in Advance.

