<?php $__env->startSection('content'); ?>
<div class="side-title">
    <h3><?php echo e($head ?? ''); ?></h3>
</div>

<div class="border-item">
    <form class="form-row" method="post" action="<?php echo e($action); ?>" enctype="multipart/form-data">
        <?php if($lesson ?? ''  && $lesson->id): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?>

        <?php $__currentLoopData = languages(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="form-group col-lg-6">
            <label><?php echo e(meta('name', $language->local) ?? __('lessons.name')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('name_'.$language->local) ? 'is-invalid' : ''); ?>" name="name_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('name', $language->local) ?? __('lessons.name')); ?>" value='<?php echo e(old("name_{$language->local}", $lesson->name['name_'.$language->local] ?? "")); ?>'/>
        </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

        <div class="form-group col-lg-6">
            <label><?php echo e(meta('course_id', getCurrentLocale()) ?? __('lessons.course_id')); ?></label>
            <select name="course_id" class="form-control course_id">
                <?php $__currentLoopData = courses(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $course): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option <?php echo e(old('course_id', $lesson ?? null ? $lesson->course_id : null) == $course->id ? 'selected' : ''); ?> value="<?php echo e($course->id); ?>"><?php echo e($course->name['name_'.getCurrentLocale()]); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>

        <div class="form-group col-lg-6">
            <label><?php echo e(meta('unit_id', getCurrentLocale()) ?? __('lessons.unit_id')); ?></label>
            <select name="unit_id" class="form-control unit_id">
                <?php if($lesson ?? null): ?>
                    <option value="<?php echo e($unit->id); ?>"><?php echo e($unit->name['name_'.getCurrentLocale()]); ?></option>
                <?php endif; ?>
            </select>
        </div>

        <div class="form-group col-lg-12">
            <label><?php echo e(meta('url', getCurrentLocale()) ?? __('lessons.url')); ?> </label>
            <input type="text" class="form-control <?php echo e($errors->has('url') ? 'is-invalid' : ''); ?>" name="url" placeholder="<?php echo e(meta('url', getCurrentLocale()) ?? __('lessons.name')); ?>" value='<?php echo e(old("url", $lesson->url ?? "")); ?>'/>
        </div>

        <div class="text-center mt-5 col-12">
            <button class="butn"><span><?php echo e(__('dashboard.save')); ?></span></button>
        </div>
    </form>
</div>

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


<?php $__env->startSection('inner_js'); ?>
    <!-- Editor JS files -->









    <script>
        $(document).ready(function () {
            $('.course_id').change(async function (e) {
                e.preventDefault();
                let data = {course_id:$(this).val()},
                    url = "<?php echo e(route('lessons.getCourseUnit')); ?>",
                    method = 'get';

                const response=await ajax({
                    url,
                    data,
                    dataType: 'html',
                    method
                });

                if (response) {
                    $('.unit_id').html(response);
                }
            });
        });
    </script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\wamp64\www\mkn\resources\views/admin/lessons/form.blade.php ENDPATH**/ ?>