<div class="table-responsive">
    <table id="example" class="table table-bordered align-middle" style="width:100%">
        <thead class="table-light">
            <tr>
                <th class="thbutton">Sl No</th>
                <th>Doctor</th>
                <th>Shift</th>
                <th>Appointment Day</th>
                <th>Priority</th>
                <th>Add Days</th>
                <th class="thbutton">Status</th>
                @if(in_array('appointment-doctor-schedule-edit', $authRolePermissions))
                <th class="thbutton">Edit</th>
                @endif
                @if(in_array('appointment-doctor-schedule-delete', $authRolePermissions))
                <th class="thbutton">Delete</th>
                @endif
            </tr>
        </thead>
        <tbody>
            @php $i=1;@endphp
            @if(count($data)>0)
                @foreach($data as $key=> $list)
                <tr>
                        <td>{{$data->firstItem() + $key}}</td>
                        <td>{{ $list->getDoctor->getAccount->name ?? '-' }}</td>
                        <td>{{ $list->getShift->name ?? '-' }}</td>
                        <td>
                            @php
                                $days = explode(',', $list->day);
                            @endphp
                            @if (!empty($day))
                                
                            @foreach ($days as $day)
                                {{ daysOfWeek($day) ?? '-' }}
                                @if (!$loop->last)
                                    , 
                                @endif
                            @endforeach
                            @endif
                        </td>
                        <td>{{$list->priority}}</td>
                        <td>
                            <div class="btn-group" style="width: 50">
                                <button data-id="{{ $list->doctor_id }}" class="btn btn-secondary days" data-bs-toggle="modal" data-bs-target="#commonModal" title="Edit" data-doctor_id="{{ $list->doctor_id }}" data-shift_id="{{ $list->shift_id }}">
                                    <i class="bi bi-clipboard-plus-fill text-white"></i>
                                </button>
                                {{-- <a href="{{ route('add-days', ['id' => $list->id]) }}" class="btn btn-success" style="color: white">Days</a> --}}
                            </div>
                        </td>
                        <td>
                            <div class="form-check form-check-inline{{$i}}">
                                <input class="form-check-input{{$i}} btn-lg changeStatusCustom" type="checkbox" id="inlineCheckbox{{$i}}" data-url="{{route('appointment-doctor-schedule.changestatus')}}" data-id="{{$list->id}}" data-status="{{$list->status=='0' ? '1' : '0'}}" {{ $list->status=='1' ? 'checked' : ''}}>
                            </div>
                        </td>
                        @if(in_array('appointment-doctor-schedule-edit', $authRolePermissions))
                        <td>
                            <button data-id="{{ $list->doctor_id }}" class="btn btn-warning edit" data-bs-toggle="modal" data-bs-target="#commonModal" title="Edit">
                                <i class="bi bi-pencil-square text-white"></i>
                            </button>
                        </td>
                        @endif
                        @if(in_array('appointment-doctor-schedule-delete', $authRolePermissions))
                        <td>
                            <a data-url="{{route('appointment-doctor-schedule.destroy')}}" data-id="{{$list->doctor_id}}" class="btn btn-danger deleteDataCustom" href="#" class="text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Delete">
                                <i class="bi bi-trash text-white"></i>
                            </a>
                        </td>
                        @endif
                    </tr>
                    @php $i++; @endphp
                @endforeach
            @else
                <tr>
                    <td colspan="5">No Data Found</td>
                </tr>
            @endif
        </tbody>
    </table>
</div>
<nav class="float-start mt-2">
    <ul class="pagination">
        {!! $data->onEachSide(0)->render('appointment-doctor-schedule.pagination') !!}
    </ul>
</nav>
</div>

