<?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($attribute ?? ''  && $attribute->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) ?? __('attributes.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) ?? __('attributes.name')); ?>" value='<?php echo e(old("name_{$language->local}", $attribute[$language->local]->name ?? "")); ?>'/>
                </div>

            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            <div class="col-12">
                    <div  class="row pricing-list-item border-item mb-4" style="background-color: white;height:auto">
                        <div class="col-lg-12">
                            <h3> <?php echo e(__('attributes.choices')); ?> </h3>
                            <div class="col-lg-12" style="height:100%;" id="choices">
                                <?php if($attribute ?? ''  && $attribute->id): ?>
                                    <?php $__currentLoopData = $attr_choices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$choice): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="row pricing-list-item border-item mb-4"  style="background-color: rgba(21,97,203,0.1);height:auto">
                                            <div class="form-group col-lg-6">
                                                <label><?php echo e(__('attributes.choice')); ?></label>
                                                <select name="choices[<?php echo e($key); ?>][id]" class="form-control">
                                                    <?php $__currentLoopData = $choices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option <?php echo e($choice->choice_id == $row->id ? 'selected' : ''); ?> value="<?php echo e($row->id); ?>"><?php echo e($row->currentLangauge->name); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                            <div class="form-group col-lg-4"></div>
                                            <div class="form-group col-lg-2" style="font-size: 30px;margin-top:35px;">
                                                <i class="fas fa-times-circle" onclick="remove(this)"></i>
                                            </div>

                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-lg-12">
                            <a style="cursor: pointer;" <?php if($attribute ?? ''  && $attribute->id): ?> data-id="<?php echo e(count($choices)); ?>" <?php else: ?> data-id="0" <?php endif; ?> onclick="addchoice(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("attributes.addchoice")); ?></a>
                        </div>
                    </div>
                </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 src="<?php echo e(asset('/assets/admin/js/lib/tinymce.min.js')); ?>"></script>
    <script>
        function addchoice(elem)
        {
            var num = $(elem).attr('data-id');
            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_addchoice,
                type : 'GET',
                data : 'key='+num,

                success:function(data)
                {
                    $('#choices').append(data);
                }
            })
        }
        function remove(elem){
            $(elem).closest('.row').remove();
        }
        function typeSelect(elem)
        {
            let data = $(elem).val()
            if(data == 'main')
            {
                $('#attribute_id').hide();
                $('#choices_id').hide();
            }
            else
            {
                $('#attribute_id').show();
                $('#choices_id').show();
            }
        }

        function statusSelect(elem)
        {
            let data = $(elem).val()
            if(data == 'one')
            {
                $('#types').hide();
                $('#attribute_id').hide();
                $('#choices_id').hide();
            }
            else
            {
                $('#types').show();
                $('#attribute_id').show();
                $('#choices_id').show();
            }
        }

        function attributeSelect(elem)
        {
            let data = $(elem).val()
            $.ajax({
                url : url_choices_attribute,
                type : 'GET',
                data : 'attribute_id='+data,
                success:function(data)
                {
                    $('#choice_id').html(data);
                }
            })
        }

        $('#status').trigger('change');
        $('#type').trigger('change');
    </script>
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            url_addchoice = <?php echo json_encode(url(getCurrentLocale().'/admin/attributes/addChoice')); ?>,
            url_choices_attribute = <?php echo json_encode(url(getCurrentLocale().'/admin/attributes/choices')); ?>,
            currentLanguage = "<?php echo e(getCurrentLocale()); ?>",
            imagePath = "<?php echo e(asset('')); ?>";
    </script>
    <script src="<?php echo e(asset('assets/admin/js/editor.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lfm.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/articles.js')); ?>"></script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/city/resources/views/admin/attributes/form.blade.php ENDPATH**/ ?>