
<?php $__env->startSection('main-container'); ?>
<main id="main" class="main">
<?php echo $__env->make('cdn', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<h4>Roles</h4>
  <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('roles.create')): ?>
<div class="text-end mb-2">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addRole-<?php echo e($permissions); ?>"><i class="bi bi-plus-circle-fill"></i> Add Role</button>
</div>
<?php endif; ?>
<table class="table table-striped display nowrap" id="tabl">
            <thead>
                <tr>
                    <th>S.No</th>
                    <th>Role</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody> 
              <?php $__currentLoopData = $roles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e(++$key); ?></td>
                        <td style="text-transform:capitalize;"><?php echo e(substr($value->name, strpos($value->name, '_') + 1)); ?></td>
                        <td>

                           <a href="<?php echo e(url('permissions/'.$value->id)); ?>" ><button type="button" class="btn btn-warning" style="border-radius:12px;">Permission</button></a>
                          <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('roles.edit')): ?>
                          <a class="btn " role="button" data-toggle="modal" data-target="#editRole-<?php echo e($value->id); ?>"><i class="bi bi-pencil-fill" style="color:navy;"></i></a>
                          <?php endif; ?>
                            <!-- Modal -->
                            <div class="modal fade" id="editRole-<?php echo e($value->id); ?>" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                            <div class="modal-content">
                              <div class="modal-header bg-info bg-gradient">
                                <h5 class="modal-title" id="editModalLabel">Edit Role</h5>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                  <span aria-hidden="true">&times;</span>
                                </button>
                              </div>
                             
                               <form action="<?php echo e(url('role-edit/'.$value->id)); ?>" method="post">
                                <?php echo e(csrf_field()); ?>

                              
                              <div class="modal-body">
                                <div class="row mb-3">
                                          <label for="inputText" class="col-sm-2 col-form-label">Role</label>
                                          <div class="col-sm-7">
                                            <input type="text" name="name" value="<?php echo e(substr($value->name, strpos($value->name, '_') + 1)); ?>" class="form-control" style="text-transform: capitalize;" required>
                                          </div>          
                                </div>  
                              </div>
                              <div class="modal-footer">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                                <button type="submit" class="btn btn-primary">Edit</button>
                              </div>
                            </form>
                            </div>
                            </div>
                            </div>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('roles.delete')): ?>
                          <a href="<?php echo e(url('deleterole/'.$value->id)); ?>" ><button type="button" class="btn "><i class="bi bi-trash" style="color:red;"></i></button></a>
                          <?php endif; ?>
                        </td>
                           
                    </tr>
                   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
  </table>
<!-- Modal -->
<div class="modal fade" id="addRole-<?php echo e($permissions); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header  bg-info bg-gradient" >
        <h5 class="modal-title" id="exampleModalLabel">Add Role</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
       <form action="<?php echo e(url('/role-submit')); ?>" method="post">
        <?php echo e(csrf_field()); ?>

      <div class="modal-body">
        <div class="row mb-3">
                  <label for="inputText" class="col-sm-2 col-form-label">Role</label>
                  <div class="col-sm-7">
                    <input type="text" name="r_name" class="form-control" placeholder="Enter Role" required>
                  </div>
        </div>  
                 <?php $__currentLoopData = $permissions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $permission): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                     <div class="form-check form-check-inline">
                        <input class="form-check-input p-2" type="checkbox" name="permission[]" id="inlineCheckbox1" value="<?php echo e($permission->id); ?>">
                      <label class="form-check-label p-2" for="inlineCheckbox1" style="text-transform:capitalize;"><?php echo e($permission->name); ?></label>
                     </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
      </div>
      <div class="modal-footer ">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Add</button>
      </div>
    </form>
    </div>
  </div>
</div>
</main>
<script type="text/javascript">  
   $(document).ready(function () {
    $('#tabl').DataTable({
       order: [],
      columnDefs: [ { orderable: false, targets: [0,1,2] } ],
      bFilter: false, 
      bInfo: false
    });
}); 
</script>
<script type="text/javascript">
  
   $(document).on('click','.open_modal',function(){
        var url = "domain.com/yoururl";
        var role_id= $(this).val();
        $.get(url + '/' + role_id, function (data) {
            //success data
            console.log(data);
            $('#role_id').val(data.id);
            $('#name').val(data.name);
           $('#btn-save').val("update");
           
        }) 
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('frontend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/wwwtechturtlecon/public_html/lms.techturtleconsultant.com/resources/views/frontend/rolespage.blade.php ENDPATH**/ ?>