

<?php $__env->startSection('content'); ?>
<div class="container-xxl flex-grow-1 container-p-y">
    <div class="card">
        <div class="card-header">
            <div class="row align-items-center">
                <div class="col">
                    <h5 class="mb-0">Courses</h5>
                </div>
                <div class="col text-end">
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('courses create')): ?>
                        <a href="<?php echo e(route('courses.create')); ?>" class="btn btn-primary">Add Course</a>
                    <?php endif; ?>
                </div>
            </div>
            <hr/>
        </div>

        <div class="card-body">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(session('success')): ?>
                <div class="alert alert-success"><?php echo e(session('success')); ?></div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <div class="table-responsive">
                <table class="table" id="bookings-table">
                    <thead>
                        <tr>
                            <th>ID</th>
                          
                            <th>Title</th>
                            <th>Category</th>
                             <th>Teacher</th>
                            <th>Status</th>
                            <th>Created</th>
                            <th style="width:260px;">Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($course->id); ?></td>
                            

                            
                                
                            <td><?php echo e($course->title); ?></td>
                            <td><?php echo e($course->category?->name ?? 'N/A'); ?></td>
                            <td><?php echo e($course->teacher?->name ?? 'N/A'); ?></td>
                            <td>
                                <span class="badge bg-<?php echo e($course->status === 'approved' ? 'success' : ($course->status === 'rejected' ? 'danger' : 'warning')); ?>">
                                    <?php echo e(ucfirst($course->status)); ?>

                                </span>
                            </td>
                            <td><?php echo e($course->created_at?->format('Y-m-d')); ?></td>
                            <td>
                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('courses view')): ?>
                                    <a class="btn btn-sm btn-info" href="<?php echo e(route('courses.show', $course)); ?>">View</a>
                                <?php endif; ?>

                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('courses update')): ?>
                                    <a class="btn btn-sm btn-warning" href="<?php echo e(route('courses.edit', $course)); ?>">Edit</a>
                                <?php endif; ?>

                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if (\Illuminate\Support\Facades\Blade::check('role', 'master admin')): ?>
                                    <form class="d-inline" method="POST" action="<?php echo e(route('courses.approve', $course)); ?>">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('PATCH'); ?>
                                        <button class="btn btn-sm btn-success" type="submit">Approve</button>
                                    </form>

                                    <form class="d-inline" method="POST" action="<?php echo e(route('courses.reject', $course)); ?>">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('PATCH'); ?>
                                        <button class="btn btn-sm btn-secondary" type="submit">Reject</button>
                                    </form>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('courses delete')): ?>
                                    <form class="d-inline" method="POST" action="<?php echo e(route('courses.destroy', $course)); ?>"
                                          onsubmit="return confirm('Delete this course?');">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button class="btn btn-sm btn-danger" type="submit">Delete</button>
                                    </form>
                                <?php endif; ?>


                                
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    </tbody>
                </table>
            </div>

        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('script'); ?>
<script>
$(document).ready(function () {
    $('#bookings-table').DataTable({
        responsive: false,
        scrollX: true,
        pageLength: 10,
        lengthMenu: [5, 10, 25, 50, 100],
        order: [[0, 'asc']],
        columnDefs: [{ orderable: false, targets: -1 }]
    });
});
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\xampp\htdocs\G_desizn\digitizing-academy\resources\views/courses/index.blade.php ENDPATH**/ ?>