<div class="card custom-border" style="border: 1px solid #ccc">
    <div class="card-header">
        <h5 style="margin: 0">Thông tin môn học</h5>
    </div>
    <div class="card-body">
        <div class="form-group">
            <label for="coure_id">Ngành học</label>
            <select class="form-control setupSelect2" id="coure_id" name="coure_id">
                <option>--Chọn ngành học--</option>
                <?php $__currentLoopData = $departments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($department->id); ?>"
                            <?php echo e(old('coure_id', $subject->coure_id ?? '') == $department->id ? 'selected' : ''); ?>>
                        <?php echo e($department->name); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['coure_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
            <label id="coure_id-error" class="error mt-2 text-danger" for="coure_id"><?php echo e($message); ?></label>
            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>


        <div class="form-group">
            <label for="major_id">Chuyên ngành</label>
            <select class="form-control setupSelect2" id="major_id" name="major_id">
                <option>--Chọn chuyên ngành--</option>
                <?php $__currentLoopData = $majors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $major): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($major->id); ?>"
                            <?php echo e(old('major_id', $subject->major_id ?? '') == $major->id ? 'selected' : ''); ?>>
                        <?php echo e($major->name); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['major_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
            <label id="major_id-error" class="error mt-2 text-danger" for="major_id"><?php echo e($message); ?></label>
            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>


        <div class="form-group">
            <label for="subject_type_id">Hình thức học</label>
            <select class="form-control setupSelect2" id="subject_type_id" name="subject_type_id">
                <?php $__currentLoopData = $subjectTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subjectType): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($subjectType->id); ?>"
                            <?php echo e(old('subject_type_id', $subject->subject_type_id ?? '') == $subjectType->id ? 'selected' : ''); ?>>
                        <?php echo e($subjectType->name); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <?php $__errorArgs = ['subject_type_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
            <label id="subject_type_id-error" class="error mt-2 text-danger" for="subject_type_id"><?php echo e($message); ?></label>
            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>

        <div class="form-group">
            <label for="status">Trạng thái</label>
            <select class="form-control setupSelect2" id="status" name="status">
                <option value="0" <?php echo e(old('status', $subject->status ?? '') == 0 ? 'selected' : ''); ?>>Hoạt động</option>
                <option value="1" <?php echo e(old('status', $subject->status ?? '') == 1 ? 'selected' : ''); ?>>Không hoạt động</option>
            </select>
            <?php $__errorArgs = ['status'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
            <label id="status-error" class="error mt-2 text-danger" for="status"><?php echo e($message); ?></label>
            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
        </div>
    </div>
</div>


<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    $(document).ready(function() {
        $('#coure_id').change(function() {
            var departmentId = $(this).val();

            if(departmentId) {
                $.ajax({
                    url: '<?php echo e(route('majors.by.department')); ?>',
                    type: 'GET',
                    data: { coure_id: departmentId },
                    success: function(data) {
                        $('#major_id').empty();
                        $('#major_id').append('<option value="">Chọn ngành học</option>'); // Thêm option mặc định
                        $.each(data, function(key, value) {
                            $('#major_id').append('<option value="'+ value.id +'">'+ value.name +'</option>');
                        });
                    }
                });
            } else {
                $('#major_id').empty();
                $('#major_id').append('<option value="">Chọn ngành học</option>'); // Thêm option mặc định
            }
        });
    });
</script>
<?php /**PATH C:\laragon\www\3_LARAVEL\SchoolManagementSystem\SchoolManagementSystem\resources\views/admin/subject/subject/components/aside.blade.php ENDPATH**/ ?>