

<?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">Chat with Students 1</h5>
                    <small class="text-muted">Select a course to see enrolled students</small>
                </div>
            </div>
            <hr class="mb-0"/>
        </div>

        <div class="card-body">

            
            <form method="GET" action="<?php echo e(route('teacher.chats.students')); ?>" class="row g-2 mb-3">
                <div class="col-md-6">
                    <label class="form-label">Course</label>
                    <select name="course_id" class="form-control" onchange="this.form.submit()">
                        <option value="">-- Select Course --</option>
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $courses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($c->id); ?>" <?php if((string)$selectedCourseId === (string)$c->id): echo 'selected'; endif; ?>>
                                <?php echo e($c->title); ?>

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

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(!$selectedCourseId): ?>
                <div class="alert alert-info mb-0">
                    Please select a course to view students.
                </div>
            <?php else: ?>

                <div class="d-flex align-items-center justify-content-between mb-2">
                    <div>
                        <strong>Course:</strong> <?php echo e($selectedCourse?->title); ?>

                    </div>
                    <div class="text-muted">
                        Total Students: <?php echo e($students->count()); ?>

                    </div>
                </div>

                <div class="table-responsive">
                    <table <?php if($students->count() > 0): ?> id="bookings-table" <?php endif; ?>
                           class="table table-bordered align-middle text-center">
                        <thead>
                            <tr>
                                <th style="width:80px;">#</th>
                                <th>Student Name</th>
                                <th style="width:220px;">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $students; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $idx => $stu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($idx + 1); ?></td>
                                    <td><?php echo e($stu->name); ?></td>
                                    <td>
                                        
                                        <a class="btn btn-primary btn-sm"
                                           href="<?php echo e(route('chats.conversation', $stu->id)); ?>?course_id=<?php echo e($selectedCourseId); ?>">
                                            Start Chat
                                        </a>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="3">No students enrolled in this course.</td>
                                </tr>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </tbody>
                    </table>
                </div>

            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

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

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