<div class="row">
    <div class="col-lg-12">
        <?php $__currentLoopData = $websites; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $website): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="row align-items-center">
                <div class="d-flex align-items-center col-lg-4" style="min-height: 83px;">
                    <input type="hidden" class="mb-2 mr-2" name="publish[<?php echo e($website->id); ?>][is_checked]" value="0">
                    <?php
                        $entityPublishSite = optional(optional($entity->publish)->where('site_id', $website->id))->first()
                    ?>
                    <input type="checkbox"
                           class="mb-2 mr-2 website-checker"
                           name="publish[<?php echo e($website->id); ?>][is_checked]"
                           value="1"
                           id="site_<?php echo e($website->id); ?>"
                           <?php if(old('publish.' . $website->id . '.is_checked',$entityPublishSite ?  1 : 0) == 1): ?> checked <?php endif; ?>
                    >
                    <label class="control-label" for="site_<?php echo e($website->id); ?>"><?php echo e($website->short_title); ?></label>
                </div>
                <div style="display: none;" class="col-lg-8" data-id="site_<?php echo e($website->id); ?>">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="control-label"><?php echo app('translator')->get('Kategorija'); ?></label>
                                <div class="">
                                    <?php
                                        $entityPublishCategory =  optional(optional(optional($entity->publish)->where('site_id', $website->id))->first())->category_id;
                                        $selectedCat = collect(json_decode($categories, true))->filter(function($value, $key) use ($entityPublishCategory, $website){
                                                          return $value['id'] == old('publish.' . $website->id . '.category_id', $entityPublishCategory);
                                                        })->first();
                                    ?>
                                    <select name="publish[<?php echo e($website->id); ?>][category_id]"
                                            class="form-control select-category" data-website-id="<?php echo e($website->id); ?>"
                                            data-website-name="<?php echo e($website->short_title); ?>">
                                        <?php if(!empty($selectedCat) && count($selectedCat)): ?>
                                            <option value="<?php echo e($selectedCat['id']); ?>"><?php echo e($selectedCat['text']); ?></option>
                                        <?php endif; ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="control-label"><?php echo app('translator')->get('Podkategorija'); ?></label>
                                <div class=""
                                        <?php
                                            $entityPublishSubCategory =  optional(optional(optional($entity->publish)->where('site_id', $website->id))->first())->subcategory_id;
                                            $selectedSubCat = collect(json_decode($subCategories, true))->filter(function($value, $key) use ($entityPublishSubCategory, $website){
                                                                return $value['id'] == old('publish.' . $website->id . '.subcategory_id', $entityPublishSubCategory);
                                                        })->first();
                                        ?>>
                                    <select name="publish[<?php echo e($website->id); ?>][subcategory_id]"
                                            class="form-control select-subcategory" data-website-id="<?php echo e($website->id); ?>"
                                            data-website-name="<?php echo e($website->short_title); ?>">
                                        <?php if(!empty($selectedSubCat) && count($selectedSubCat)): ?>
                                            <option value="<?php echo e($selectedSubCat['id']); ?>"><?php echo e($selectedSubCat['text']); ?></option>
                                        <?php endif; ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    </div>
</div>

<?php $__env->startPush('footer_scripts'); ?>
    <script>
        $(document).ready(function () {

            function toggleShowSelect(element) {
                let catSelectors = element.parent().next();
                if (element.is(':checked')) {
                    if (!catSelectors.is(':visible')) {
                        catSelectors.show();
                    }
                } else {
                    if (catSelectors.is(':visible')) {
                        catSelectors.hide();
                    }
                }
            };

            $('.article-categories input.website-checker').on('click', function () {
                toggleShowSelect($(this));
            });

            $('.article-categories input.website-checker').each(function (key, item) {
                toggleShowSelect($(this));
            });

        });

    </script>
<?php $__env->stopPush(); ?><?php /**PATH /opt/cms/resources/views/articles/partials/form/categories.blade.php ENDPATH**/ ?>