
    <div class="card mb5 collapse_div">
        <div class="card-header text-white blue-gradient" role="tab" id="<?php echo e(isset($title) ? str_slug($title) :  'permissionHeading'); ?>">
          
            <a data-toggle="collapse" class="other" href="#dd-<?php echo e(isset($title) ? str_slug($title) :  'permissionHeading'); ?>" aria-expanded="<?php echo e(isset($closed) ? $closed : 'true'); ?>">
                    <?php echo e(isset($title) ? $title : 'Override Permissions'); ?> <?php echo isset($user) ? '<span class="text-danger">(' . $user->getDirectPermissions()->count() . ')</span>' : ''; ?>

            </a>
       
        </div>

            <div id="dd-<?php echo e(isset($title) ? str_slug($title) :  'permissionHeading'); ?>" data-parent="#accordion" class="panel-collapse collapse <?php echo e(isset($closed) ? $closed : ''); ?> p15"  aria-labelledby="<?php echo e(isset($title) ? str_slug($title) :  'permissionHeading'); ?>">
                <div class="panel-body p15">
                 <?php if(isset($modules)){ 
    
                      if(!isset($role_name)){
                       
                        $role_name="User";
                      }
              
                    ?>
                    
                   <?php $__currentLoopData = $modules; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $module): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                      <div class="row mb5 checkbox_all_div">
                           <?php $select_all_id=$module->module_code.$flag; ?>
                              <div class="col-md-12">
                                  <h6><span class="badge badge-info"><?php echo e($module->module_code); ?> <?php echo e($module->module_name); ?></span>&nbsp; <?php if($role_name!='Admin'): ?> <input type="checkbox" class="select_all" id="<?php echo e($select_all_id); ?>"/> Selecct All <?php endif; ?> </h6>
                              </div>
                              <div class="col-md-12 pl35 pr35 ">
                                <div class="row role_permission_div pt10">
                                    <?php 
                                          $total=0;
                                          $checked_data=0;
                                    ?>
                                    <?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                     
                                    
                                       <?php if($module->module_code==$perm->module): ?>
                                            <?php $total +=1; ?>
                                            <?php
                                                $per_found = null;

                                                if( isset($role) ) {
                                                    $per_found = $role->hasPermissionTo($perm->name);
                                                }

                                                if( isset($user)) {
                                                    $per_found = $user->hasDirectPermission($perm->name);
                                                }
                                          
                                                if($per_found==true)
                                                    $checked_data +=1;
                                            ?>
                                           

                                            <div class="col-md-3">
                                                <div class="checkbox">
                                                    <label class="<?php echo e(str_contains($perm->name, 'delete') ? 'text-danger' : ''); ?>">
                                                        <?php echo Form::checkbox("permissions[]", $perm->name, $per_found, isset($options) ? $options : ['class' => 'child_checkbox']); ?> <?php echo e($perm->name); ?>

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

                                   <?php 
                                      if($role_name!='Admin'){ 
                                         if($total==$checked_data){ ?>
                                             <script>
                                                  $('#<?php echo e($select_all_id); ?>')[0].checked = true; 
                                             </script>
                                   <?php  }
                                      }
                                     ?>
                                 </div>
                             </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    
                    <?php }else{ ?>
                        <div class="row mb5">
                               <?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $perm): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php
                                                $per_found = null;

                                                if( isset($role) ) {
                                                    $per_found = $role->hasPermissionTo($perm->name);
                                                }

                                                if( isset($user)) {
                                                    $per_found = $user->hasDirectPermission($perm->name);
                                                }
                                            ?>

                                            <div class="col-md-3">
                                                <div class="checkbox">
                                                    <label class="<?php echo e(str_contains($perm->name, 'delete') ? 'text-danger' : ''); ?>">
                                                        <?php echo Form::checkbox("permissions[]", $perm->name, $per_found, isset($options) ? $options : []); ?> <?php echo e($perm->name); ?>

                                                    </label>
                                                </div>
                                            </div>
                                   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
               
                         </div>
                    
                    <?php } ?>
                        <?php 
                        if(isset($role_name)){
                            if($role_name!='Admin'){   ?>
                                 <?php if(auth()->check() && auth()->user()->hasRole($role_name)): ?>
   
                                 <?php else: ?>
                                   <div class="row justify-content-end">
                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('edit_roles')): ?>
                                            <?php echo Form::submit('Save', ['class' => 'btn btn-sm btn-success pull-right waves-effect waves-light']); ?>

                                        <?php endif; ?>
                                   </div>
                            
                                 <?php endif; ?>
                            <?php
                             } 
                        } ?>
                </div>
            </div>
    </div>


