

<?php $__env->startSection('content'); ?>
    <section class="py-4">
        <div class="container-fluid px-lg-4">
            
            <h4 class="fw-bold mb-3">Halaman Video Kegiatan</h4>

            
            <button class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#tambahVideo">
                Tambah Video
            </button>

            
            <?php if(session()->has('success')): ?>
                <div class="alert alert-success alert-dismissible fade show">
                    <strong>Informasi :</strong> <?php echo e(session('success')); ?>

                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            <?php endif; ?>

            
            <?php if($errors->any()): ?>
                <div class="alert alert-danger alert-dismissible fade show">
                    <ul class="mb-0">
                        <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <li><?php echo e($error); ?></li>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </ul>
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            <?php endif; ?>

            
            <div class="table-responsive">
                <table class="table table-bordered align-middle">
                    <thead class="table-light">
                        <tr>
                            <th width="50">#</th>
                            <th>Judul</th>
                            <th width="260">Preview Video</th>
                            <th width="150">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__currentLoopData = $videos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $no => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                
                                <td><?php echo e($no + 1); ?></td>

                                
                                <td><?php echo e($item->judul); ?></td>

                                
                                <td>
                                    <div class="ratio ratio-16x9">
                                        <iframe src="https://www.youtube.com/embed/<?php echo e($item->youtube_code); ?>"
                                            title="YouTube video" allowfullscreen>
                                        </iframe>
                                    </div>
                                </td>

                                
                                <td>
                                    
                                    <button class="btn btn-warning btn-sm w-100 mb-1" data-bs-toggle="modal"
                                        data-bs-target="#editVideo<?php echo e($item->id); ?>">
                                        Edit
                                    </button>

                                    
                                    <form action="<?php echo e(route('video.destroy', $item->id)); ?>" method="POST">
                                        <?php echo csrf_field(); ?>
                                        <button onclick="return confirm('Yakin ingin menghapus video?')"
                                            class="btn btn-danger btn-sm w-100">
                                            Hapus
                                        </button>
                                    </form>
                                </td>
                            </tr>

                            
                            <div class="modal fade" id="editVideo<?php echo e($item->id); ?>" tabindex="-1">
                                <div class="modal-dialog modal-lg modal-dialog-centered">
                                    <div class="modal-content">

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

                                        
                                        <div class="modal-body">
                                            <form action="<?php echo e(route('video.update', $item->id)); ?>" method="POST">
                                                <?php echo csrf_field(); ?>

                                                <div class="row">
                                                    
                                                    <div class="col-md-6 mb-3">
                                                        <label class="form-label">Preview</label>
                                                        <div class="ratio ratio-16x9">
                                                            <iframe
                                                                src="https://www.youtube.com/embed/<?php echo e($item->youtube_code); ?>"
                                                                allowfullscreen>
                                                            </iframe>
                                                        </div>
                                                    </div>

                                                    
                                                    <div class="col-md-6">
                                                        
                                                        <div class="mb-3">
                                                            <label class="form-label">Judul Video</label>
                                                            <input type="text" name="judul" class="form-control"
                                                                value="<?php echo e($item->judul); ?>" required>
                                                        </div>

                                                        
                                                        <div class="mb-3">
                                                            <label class="form-label">
                                                                YouTube Code
                                                                <small class="text-muted">(contoh: dQw4w9WgXcQ)</small>
                                                            </label>
                                                            <input type="text" name="youtube_code" class="form-control"
                                                                value="<?php echo e($item->youtube_code); ?>" required>
                                                        </div>

                                                        
                                                        <button type="submit" class="btn btn-primary w-100">
                                                            Update
                                                        </button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>

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

    
    <div class="modal fade" id="tambahVideo" tabindex="-1">
        <div class="modal-dialog modal-md modal-dialog-centered">
            <div class="modal-content">

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

                
                <div class="modal-body">
                    <form action="<?php echo e(route('video.store')); ?>" method="POST">
                        <?php echo csrf_field(); ?>

                        
                        <div class="mb-3">
                            <label class="form-label">Judul Video</label>
                            <input type="text" name="judul" class="form-control" required>
                        </div>

                        
                        <div class="mb-3">
                            <label class="form-label">
                                YouTube Code
                                <small class="text-muted">(ambil dari URL)</small>
                            </label>
                            <input type="text" name="youtube_code" class="form-control" placeholder="contoh: dQw4w9WgXcQ"
                                required>
                        </div>

                        
                        <button type="submit" class="btn btn-primary w-100">
                            Simpan
                        </button>
                    </form>
                </div>

            </div>
        </div>
    </div>
<?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/video/index.blade.php ENDPATH**/ ?>