<div class="col-md-12">
    <div class="d-flex justify-content-between">
        <div class="form-check">
            <label class="form-check-label">
                <input class="form-check-input" type="checkbox" id="checkAll">Check all
            </label>
        </div>
        <button type="submit" class="btn btn-primary">Give permissions</button>

    </div>
    <hr>
</div>

<?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(strpos($item->name, '*') == true): ?>
<?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(!$loop->first): ?>
</div>
</div>
<?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
<div class="col-lg-6 col-xl-4">
    <div class="list-group mb-3 card-equal">
        <li class="list-group-item list-group-item-action" style="background-color: lightblue;">

            <div class="form-check">
                <label class="form-check-label">
                    <input class="form-check-input checkbox subCheckAll" type="checkbox" name="permissions[]"
                        value="<?php echo e($item->name); ?>" <?php if($role->hasPermissionTo($item->name)): ?> checked
                    <?php endif; ?>><?php echo e($item->name); ?>

                </label>
            </div>
        </li>
        <?php else: ?>
        <li class="list-group-item list-group-item-action">
            <div class="form-check">
                <label class="form-check-label">
                    <input class="form-check-input checkbox" type="checkbox" name="permissions[]"
                        value="<?php echo e($item->name); ?>" <?php if($role->hasPermissionTo($item->name)): ?> checked
                    <?php endif; ?>><?php echo e($item->name); ?>

                </label>
            </div>
        </li>
        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

        <script>
            // Check All checkbox change event handler
        $('#checkAll').change(function() {
            $('.checkbox').prop('checked', $(this).prop('checked'));
        });

        // Individual checkbox change event handler
        $('.checkbox').change(function() {
            // If all checkboxes are checked, check the Check All checkbox
            if ($('.checkbox:checked').length === $('.checkbox').length) {
                $('#checkAll').prop('checked', true);
            } else {
                $('#checkAll').prop('checked', false);
            }
        });
        $('.subCheckAll').change(function() {
            var chkVal = $(this).val();
            var valPrefix = chkVal.split('.')[0];
            var isChecked = $(this).prop('checked');
            $('.checkbox').each(function() {
                var checkboxValuePrefix = $(this).val().split('.')[0];

                if (checkboxValuePrefix == valPrefix) {
                    $(this).prop('checked', isChecked);
                }
            });
        });
        </script><?php /**PATH /home/faraaadm/library.farau.edu.af/resources/views/user/permissions.blade.php ENDPATH**/ ?>