<?php $__env->startSection('title', 'Permissions'); ?>

<?php $__env->startSection('page-header'); ?>
<header class="header bg-ui-general">
     <div class="header-info">
          <h1 class="header-title">
               <strong>Permissions</strong>
          </h1>
     </div>

     <div class="header-action">
          <nav class="nav">
               <a class="nav-link" href="<?php echo e(route('roles.index')); ?>">
                    Roles
               </a>
               <a class="nav-link active" href="<?php echo e(request()->url()); ?>">
                    <i class="fa fa-plus"></i>
                    Permissions
               </a>
          </nav>
     </div>
</header>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="col-12">
    <div class="card">
        <div class="card-header">
            <h3>Update - <span style="text-transform: "><?php echo e($role->name); ?></span> - Permissions</h3>
            
            <span class=""><label><input type="checkbox" id="select-all" class="mr-2 ml-2">Select All</label></span>
            
        </div>
        <div class="card-body all_features">


            <form action="<?php echo e(route('role_permissions.update', $role)); ?>" method="POST" class="form-row">
                <?php echo method_field('PUT'); ?>
                <?php echo csrf_field(); ?>

                <?php $__currentLoopData = $permission_groups; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $permissions): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="card col-md-6 feature_group">
                        <div class="card-header">
                            <h4 style="text-transform: capitalize" style="display: inline;"><?php echo e(str_replace('_', ' ', $key)); ?></h4>
                            <span class=""><label><input type="checkbox" class="mr-2 ml-2 select_group">Select Section</label></span>
                        </div>
                        <div class="card-body">
                            <?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="">
                                    <input type="checkbox" value="<?php echo e($permission->name); ?>" name="permissions[]"
                                        <?php if($role->hasPermissionTo($permission->name)): ?> CHECKED <?php endif; ?> class="feature"> <span
                                        style="text-transform: capitalize"><?php echo e(str_replace('-',' - ',str_replace('_', ' ', $permission->name))); ?></span>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <div class="form-group col-12">
                    <input type="submit" class="btn btn-success" value="Update Permissions">
                </div>
                
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <script>
        $('#select-all').click(function(event) {
            // alert('hello');
            $('.all_features').find("input[type='checkbox']").prop('checked', this.checked);
            // if (this.checked) {
            //     // alert('checked');
            //     // Iterate each checkbox
            //     $('.feature:checkbox').each(function() {
            //         this.checked = true;
            //     });
            // } else {
            //     $('.feature:checkbox').each(function() {
            //         this.checked = false;
            //     });
            // }
        });

        $(".select_group").click(function(event){
            var parent = $(this).closest('.feature_group');
            parent.find("input[type='checkbox']").prop('checked', this.checked);
        });
    </script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/demosoftghor/sm.demo.softghor.com/resources/views/pages/role_permission/edit.blade.php ENDPATH**/ ?>