<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-sm-12">
        <div class="page-title-box">
            <div class="float-end">
                <a href="<?php echo e(route('settings.roles.create')); ?>" class="btn btn-primary btn-sm">Create New Role</a>
            </div>
            <h4 class="page-title">Roles Management</h4>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <table class="table table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Role Name</th>
                            <th>Guard</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($loop->iteration); ?></td>
                            <td><?php echo e(ucfirst($role->name)); ?></td>
                            <td><?php echo e($role->guard_name); ?></td>
                            <td>
                                <a href="<?php echo e(route('settings.roles.edit', $role->id)); ?>" class="btn btn-sm btn-info">Edit</a>
                                <button class="btn btn-sm btn-danger delete-role" data-id="<?php echo e($role->id); ?>">Delete</button>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
$(document).ready(function() {
    $('.delete-role').click(function() {
        if (confirm('Are you sure you want to delete this role?')) {
            let id = $(this).data('id');
            let url = "<?php echo e(route('settings.roles.destroy', ':id')); ?>".replace(':id', id);
            
            $.ajax({
                url: url,
                type: 'DELETE',
                data: { _token: "<?php echo e(csrf_token()); ?>" },
                success: function(response) {
                    if (response.status) {
                        toastr.success(response.message);
                        location.reload();
                    }
                }
            });
        }
    });
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/codeproh/hr.vadistilleries.lk/app/Modules/PLATFORM/UserManagement/Providers/../Views/roles/index.blade.php ENDPATH**/ ?>