【发布时间】:2020-08-25 06:38:08
【问题描述】:
我的 Laravel 应用程序中有一个在线预约表格,其中一些已提交 Select Doctor 和 datepicker。
假设医生A 将在周六、周一和周三在诊所提供服务。周日、周二、周四有医生B。因此,当任何患者从Select Doctor 字段中选择医生A 时,所有周六、周一和周三的日期都将在datepicker 日历中激活,而其他日期将被停用。
我已经停用了datepicker 日历的一些选定日期。但无法禁用 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::get('/filter_available_date','frontendAppointmentController@filter_available_date');
控制器
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;
}
如何解决问题?有人帮忙吗?提前致谢。
【问题讨论】:
-
是jquery datepicker吗?
-
@EhsanMahmud...是的
-
能否提供 API 响应?
-
@EhsanMahmud....我是 Laravel 的新手。您能告诉我查找 API 响应的过程吗?
标签: php jquery laravel laravel-5 datepicker