

<?php $__env->startSection('content'); ?>
    <section class="py-4">
        <div class="container-fluid px-lg-4">

            <h4 class="fw-bold mb-3">Data Prestasi</h4>

            
            <form method="POST" action="/admin/prestasi/store" class="card shadow-sm mb-4">
                <?php echo csrf_field(); ?>
                <div class="card-body">
                    <div class="row g-3">

                        <div class="col-12 col-lg-4">
                            <div class="form-floating">
                                <input type="text" name="nama_prestasi" class="form-control" placeholder="Nama Prestasi"
                                    required>
                                <label>Nama Prestasi</label>
                            </div>
                        </div>

                        <div class="col-12 col-lg-3">
                            <div class="form-floating">
                                <select name="tingkat" class="form-select" required>
                                    <option value="">Pilih Tingkat</option>
                                    <option value="Daerah">Daerah</option>
                                    <option value="Nasional">Nasional</option>
                                    <option value="Internasional">Internasional</option>
                                </select>
                                <label>Tingkat</label>
                            </div>
                        </div>

                        <div class="col-12 col-lg-2">
                            <div class="form-floating">
                                <input type="number" name="tahun" class="form-control" placeholder="2025" required>
                                <label>Tahun</label>
                            </div>
                        </div>

                        <div class="col-12 col-lg-3 d-grid">
                            <button class="btn btn-primary btn-lg">
                                Tambah Prestasi
                            </button>
                        </div>

                    </div>
                </div>
            </form>

            
            <div class="d-block d-md-none">
                <?php $__currentLoopData = $prestasis; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="card shadow-sm mb-3">
                        <div class="card-body">

                            <h6 class="fw-bold mb-1">
                                <?php echo e($item->nama_prestasi); ?>

                            </h6>

                            <div class="mb-2">
                                <span class="badge bg-primary"><?php echo e($item->tingkat); ?></span>
                                <span class="badge bg-secondary"><?php echo e($item->tahun); ?></span>
                            </div>

                            <div class="d-grid gap-2">
                                <button class="btn btn-warning btn-sm" data-bs-toggle="modal"
                                    data-bs-target="#edit<?php echo e($item->id); ?>">
                                    Edit
                                </button>

                                <form action="/admin/prestasi/delete/<?php echo e($item->id); ?>" method="POST">
                                    <?php echo csrf_field(); ?>
                                    <button onclick="return confirm('Hapus prestasi ini?')" class="btn btn-danger btn-sm">
                                        Hapus
                                    </button>
                                </form>
                            </div>

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

            
            <div class="table-responsive d-none d-md-block">
                <table class="table table-bordered align-middle">
                    <thead class="table-light">
                        <tr>
                            <th width="50">No</th>
                            <th>Nama Prestasi</th>
                            <th width="150">Tingkat</th>
                            <th width="100">Tahun</th>
                            <th width="160">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $prestasis; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td><?php echo e($loop->iteration); ?></td>
                                <td><?php echo e($item->nama_prestasi); ?></td>
                                <td>
                                    <span class="badge bg-primary"><?php echo e($item->tingkat); ?></span>
                                </td>
                                <td><?php echo e($item->tahun); ?></td>
                                <td>
                                    <div class="d-grid gap-1">
                                        <button class="btn btn-warning btn-sm" data-bs-toggle="modal"
                                            data-bs-target="#edit<?php echo e($item->id); ?>">
                                            Edit
                                        </button>

                                        <form action="/admin/prestasi/delete/<?php echo e($item->id); ?>" method="POST">
                                            <?php echo csrf_field(); ?>
                                            <button onclick="return confirm('Hapus prestasi ini?')"
                                                class="btn btn-danger btn-sm">
                                                Hapus
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            </div>

            
            <?php $__currentLoopData = $prestasis; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="modal fade" id="edit<?php echo e($item->id); ?>" tabindex="-1">
                    <div class="modal-dialog modal-fullscreen-sm-down modal-dialog-centered">
                        <div class="modal-content">
                            <form action="/admin/prestasi/update/<?php echo e($item->id); ?>" method="POST">
                                <?php echo csrf_field(); ?>

                                <div class="modal-header">
                                    <h5 class="modal-title">Edit Prestasi</h5>
                                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                                </div>

                                <div class="modal-body">
                                    <div class="mb-3">
                                        <label class="form-label">Nama Prestasi</label>
                                        <input type="text" name="nama_prestasi" value="<?php echo e($item->nama_prestasi); ?>"
                                            class="form-control" required>
                                    </div>

                                    <div class="mb-3">
                                        <label class="form-label">Tingkat</label>
                                        <select name="tingkat" class="form-select" required>
                                            <option value="Daerah" <?php echo e($item->tingkat == 'Daerah' ? 'selected' : ''); ?>>Daerah
                                            </option>
                                            <option value="Nasional" <?php echo e($item->tingkat == 'Nasional' ? 'selected' : ''); ?>>
                                                Nasional</option>
                                            <option value="Internasional"
                                                <?php echo e($item->tingkat == 'Internasional' ? 'selected' : ''); ?>>Internasional</option>
                                        </select>
                                    </div>

                                    <div class="mb-3">
                                        <label class="form-label">Tahun</label>
                                        <input type="number" name="tahun" value="<?php echo e($item->tahun); ?>"
                                            class="form-control" required>
                                    </div>
                                </div>

                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
                                        Batal
                                    </button>
                                    <button class="btn btn-primary">
                                        Simpan Perubahan
                                    </button>
                                </div>

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

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

<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH E:\laragon\www\websekolah\resources\views/admin/prestasi/index.blade.php ENDPATH**/ ?>