<x-app-layout>
    @section('title')
        Doctors
    @endsection
    <!-- Page Heading -->
    <h1 class="h3 mb-2 text-gray-800">
        @can('Doctor create')
            <a href="{{ route('admin.doctors.create') }}" class="btn btn-primary"><i class="fas fa-plus" aria-hidden="true"></i>
                Create Doctors
            </a>
        @endcan
    </h1>
    <div class="row">
        <div class="col-12">
            @include('admin.layouts.partials.validation')
        </div>
    </div>
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">
                Listing Doctors Table
            </h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>S.No.</th>
                            <th>Doctors Name</th>
                            <th>Services Name</th>
                            <th>Status</th>
                            <th>Created At</th>
                            <th>Updated At</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>

                        @can('Doctor access')


                            @foreach ($data as $doctor)
                                <tr>
                                    <td>{{ $doctor->id }}</td>
                                    <td>{{ $doctor->name }}</td>
                                    <td>{{ $doctor->service->name }}</td>
                                    <td>
                                        @if ($doctor->status == 1)
                                            <span class="badge badge-success">Active</span>
                                        @else
                                            <span class="badge badge-danger">Deactive</span>
                                        @endif

                                    <td>{{ $doctor->created_at->diffForHumans() }}</td>
                                    <td>{{ $doctor->updated_at->diffForHumans() }}</td>
                                    <td class="d-flex">
                                        @can('Doctor edit')
                                            <a href="{{ route('admin.doctors.edit', $doctor->id) }}"
                                                class="btn btn-primary btn-sm mr-1">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                        @endcan

                                        @can('Doctor delete')
                                            <a href="{{ route('admin.doctors.destroy', $doctor->id) }}"
                                                class="btn btn-danger btn-sm" id="delete"><i class="fas fa-trash"></i>
                                            </a>
                                        @endcan

                                    </td>
                                </tr>
                            @endforeach


                        @endcan
                    </tbody>
                </table>
            </div>
        </div>
    </div>

</x-app-layout>
