<?php $__env->startSection('main-content'); ?>
<main>
    <div class="container-fluid">
        <h2 class="mt-5 mb-4">Add Role</h2>

            <div class="row">
                <div class="col-md-12">
                    <div class="card card-primary">
                        <div class="card-header">
                            <h6 class="card-title"></h6>
                        </div>
                        <div class="card-body" id="demo">


                            <form action="<?php echo e(route('admin.role_has_permissions.role')); ?>" method="POST">
                                <?php echo csrf_field(); ?>
                                <div class="form-group">
                                    <label for="name">Role Name</label>
                                    <input type="text" class="form-control" id="name" name="name" value="<?php echo e(old('name')); ?>" placeholder="Enter a Role Name">
                                </div>

                                <div class="form-group">
                                    <label for="name">Permissions</label>

                                    <div class="form-check">
                                        <input type="checkbox" onclick="allCheckBoc()" class="form-check-input" id="checkPermissionAll" value="1">
                                        <label class="form-check-label"  for="checkPermissionAll">All</label>
                                    </div>
                                    <hr>
                                    <?php $i = 1; ?>
                                    <?php $__currentLoopData = $permission_groups; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $group): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="row">
                                            <div class="col-3">
                                                <div class="form-check">
                                                    <input type="checkbox" class="form-check-input" name="Parent_<?php echo e($group->id); ?>[]" id="checkPermissionParent_<?php echo e($group->id); ?>" value="<?php echo e($group->model_name); ?>" onclick="parentIDSET(<?php echo e($group->id); ?>)">
                                                    <label class="form-check-label" for="checkPermission"><?php echo e($group->model_name); ?></label>
                                                </div>
                                            </div>

                                            <div class="col-9 role-<?php echo e($group->id); ?>-management-checkbox">
                                                <?php  $j=1; ?>
                                                <?php $__currentLoopData = $group->SubModel; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <div class="form-check">
                                                        <input type="checkbox" onclick="childIDSET(<?php echo e($group->id); ?>)" class="form-check-input checkPermission_<?php echo e($group->id); ?>" name="permissions_<?php echo e($group->id); ?>[]" id="checkPermission_<?php echo e($group->id); ?>" value="<?php echo e($permission->id); ?>">
                                                        <label class="form-check-label" for="checkPermission<?php echo e($permission->id); ?>"><?php echo e($permission->model_name); ?></label>
                                                    </div>
                                                    <?php  $j++; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <br>
                                            </div>

                                        </div>
                                        <?php  $i++; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                                </div>


                                <button type="submit" class="btn btn-primary mt-4 pr-4 pl-4">Save Role</button>
                            </form>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->

                    <!-- end -->
                </div>
            </div>

    </div>
</main>

<?php $__env->stopSection(); ?>


<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<script>
    function parentIDSET(id){
    // alert(id);

   var checkBox = $('#checkPermissionParent_' + id).is(":checked");
   if(checkBox == true){
    $(".checkPermission_" + id).prop("checked", true);
   }else{
    $(".checkPermission_" + id).prop("checked",false);
   }

}

function childIDSET(id){
    // alert(id);
    $("#checkPermissionParent_" + id).prop("checked", true);
}

function allCheckBoc(){
    // alert(id);
    var checkBox = $('#checkPermissionAll').is(":checked");
    if(checkBox == true){
        $("input[type='checkbox']").prop("checked", true);
   }else{
   
    $("input[type='checkbox']").prop("checked", false);
   }

}
</script>

<?php echo $__env->make('admin.layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/aks5g/public_html/aadhar.aks.5g.in/resources/views/admin/role/role.blade.php ENDPATH**/ ?>