<?php $__env->startSection('content'); ?>
<div class="row mb-3">
    <div class="col-md-6">
        <h2>Data User</h2>
    </div>
    <div class="col-md-6 text-end">
        <a href="<?php echo e(route('users.create')); ?>" class="btn btn-primary">Tambah User</a>
    </div>
</div>

<div class="card">
    <div class="card-body">
        <form action="<?php echo e(route('users.index')); ?>" method="GET" class="mb-4">
            <div class="input-group">
                <input type="text" name="search" class="form-control" placeholder="Cari berdasarkan nama atau NRP..." value="<?php echo e(request('search')); ?>">
                <button class="btn btn-outline-secondary" type="submit">Cari</button>
            </div>
        </form>

        <div class="table-responsive">
            <table class="table table-bordered table-hover align-middle">
                <thead class="table-light">
                    <tr>
                        <th>No</th>
                        <th>Nama</th>
                        <th>NRP (Username)</th>
                        <th>Role</th>
                        <th>Relasi Karyawan</th>
                        <th width="150">Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($users->firstItem() + $loop->index); ?></td>
                        <td><?php echo e($user->name); ?></td>
                        <td><?php echo e($user->nrp); ?></td>
                        <td>
                            <?php if($user->role === 'admin'): ?>
                                <span class="badge bg-danger">Admin</span>
                            <?php else: ?>
                                <span class="badge bg-info text-dark">Pengawas</span>
                            <?php endif; ?>
                        </td>
                        <td><?php echo e($user->karyawan ? $user->karyawan->nama : '-'); ?></td>
                        <td>
                            <form action="<?php echo e(route('users.destroy', $user->id)); ?>" method="POST" onsubmit="return confirm('Apakah Anda yakin ingin menghapus data ini?');">
                                <a href="<?php echo e(route('users.edit', $user->id)); ?>" class="btn btn-sm btn-warning">Edit</a>
                                <?php echo csrf_field(); ?>
                                <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="btn btn-sm btn-danger">Hapus</button>
                            </form>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="6" class="text-center">Data tidak ditemukan.</td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <div class="d-flex justify-content-center mt-3">
            <?php echo e($users->links('pagination::bootstrap-5')); ?>

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

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\gl-asuh\resources\views/menu/users/index.blade.php ENDPATH**/ ?>