<select id="employee" class="form-control select2bs4 @error('employee') is-invalid @enderror" data-placeholder="Select an employee" name="employee">
<option value="">Select</option>
@foreach ($users as $key => $user)
<option value="{{ $user->name }}" }}>{{ $user->name }}</option>
@endforeach
</select>
$('#schedule_table').on('click', '.btn-edit', function () {
var schedule_id = $(this).data('id');
var url = '{{ route("schedules.update","") }}' +'/'+ schedule_id;
$.ajax({
cache: false,
success: function(data){
$('#scheduleModal').modal('show');
$('.modal-title').html("Edit schedule");
$.each(data.schedules, function(index, value) {
if(value.id === schedule_id){
$('#id').val(schedule_id);
$('#employee').val(value.employee).change();
$('#datefrom').val(value.datefrom);
$('#dateto').val(value.dateto);
$('#timein').val(value.timein);
$('#timeout').val(value.timeout);
$('#hours').val(value.hours);
$('#daysoff').val(value.daysoff);
$('#scheduleForm').attr('action', url);
$('#schedule_method').attr('value', 'PATCH');
}
});
}
});
});