
<?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(); ?>

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addRole">Add Role</button>
<div class="container mt-2" style="margin-top: 100px; height: 550px;">
 <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 $role): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($role->id); ?></td>
                        <td><?php echo e($role->name); ?></td>
                        <td>
                          <a class="btn btn-primary" role="button" data-toggle="modal" data-target="#editRole-<?php echo e($role->id); ?>" style="color: white;">Edit</a>

                            <!-- Modal -->
                            <div class="modal fade" id="editRole-<?php echo e($role->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">
                                <h5 class="modal-title" id="editModalLabel">Modal title</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/'.$role->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($role->name); ?>" class="form-control" 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>


                          <a href="<?php echo e(url('permissions/'.$role->id)); ?>" ><button type="button" class="btn btn-primary" data-toggle="" data-target="">Permission</button></a>
                          <a href="<?php echo e(url('deleterole/'.$role->id)); ?>" ><button type="button" class="btn btn-primary">Delete</button></a>
                        </td>
                           
                    </tr>
                   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>

        </table>

</div>
<!-- Modal -->
<div class="modal fade" id="addRole" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</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>  
      </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">
  $('#myModal').on('shown.bs.modal', function () {
  $('#myInput').trigger('focus')
})
</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 C:\xampp\htdocs\Family\resources\views/frontend/forms-editors.blade.php ENDPATH**/ ?>