<?php
    $language_option = appSettingData('get')->language_option;
    $language_array = languagesArray($language_option);
    $files = [ 'auth', 'message', 'pagination', 'passwords', 'validation' ];
?>
<div class="row">
    <div class="col-md-4">
        <div class="form-group">
            <label for="language_option" class="form-control-label"><?php echo e(__('message.language_option')); ?></label>
            <select class="form-control select2js" name="language_option" id='change_language'>
                <?php if(count($language_array) > 0): ?>
                    <?php $__currentLoopData = $language_array; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lang): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($lang['id']); ?>" <?php echo e(config('app.locale') == $lang['id']  ? 'selected' : ''); ?> ><?php echo e($lang['title']); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <?php endif; ?>
            </select>
        </div>
    </div>
    <div class="col-md-4">
        <div class="form-group">
            <label for="selected_file" class="form-control-label"><?php echo e(__('message.select_file')); ?></label>
            <select class="form-control select2js" name="selected_file" id="selected_file">
                <?php $__currentLoopData = $files; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($value); ?>" ><?php echo e($value); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select> 
        </div>
    </div>
    <div class="col-md-12">
        <div class="language-section"></div>
    </div>
</div>
<script>
    function getLanguageFile(lang = '', file = ''){
        var url = "<?php echo e(route('getLanguageFile')); ?>";
        $.ajax({
            type: 'post',
            url: url,
            data: {
                'lang': lang,
                'file': file
            },
            success: function(res){
                $('.language-section').html(res);
            }
        });
    }
    $(document).ready(function (){
        $('.select2js').select2();
        let selectedLang = $("#change_language :selected").val();
        let selectedFile = $('#selected_file :selected').val();
        getLanguageFile(selectedLang,selectedFile)
        $(document).on('change','#change_language',function() {
            let selectedLang = $("#change_language :selected").val();
            let selectedFile = $('#selected_file :selected').val();
            getLanguageFile(selectedLang,selectedFile)
        });

        $(document).on('change','#selected_file',function() {
            let selectedLang = $("#change_language :selected").val();
            let selectedFile = $('#selected_file :selected').val();
            getLanguageFile(selectedLang,selectedFile)
        });        
    });
</script>
<?php /**PATH /www/wwwroot/mxunzo.atharvatek.com/resources/views/setting/language-setting.blade.php ENDPATH**/ ?>