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

        <h5 class="mt-4">Edit Proyek</h5>

        <div class="card">
            <div class="card-body">

                <form action="<?php echo e(route('project.update', $project->id)); ?>" method="POST" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>

                    <div class="mb-3">
                        <label class="form-label">Nama Aplikasi</label>
                        <input type="text" name="nama_aplikasi" class="form-control"
                            value="<?php echo e($project->nama_aplikasi); ?>">
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Deskripsi</label>
                        <textarea name="deskripsi" class="form-control"><?php echo e($project->deskripsi); ?></textarea>
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Link</label>
                        <input type="text" name="link" class="form-control" value="<?php echo e($project->link); ?>">
                    </div>

                    <div class="mb-3">
                        <label class="form-label">Tambah Gambar Baru</label>
                        <input type="file" name="gambar[]" class="form-control" multiple id="gambarInput">
                    </div>

                    <h6>Gambar Lama</h6>

                    <div class="row">

                        <?php $__currentLoopData = $project->images; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $img): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <div class="col-md-3 mb-3 text-center">

                                <img src="<?php echo e(asset('storage/' . $img->gambar)); ?>" class="img-fluid rounded mb-2"
                                    style="height:120px;object-fit:cover">

                                <div class="form-check">
                                    <input type="checkbox" name="hapus_gambar[]" value="<?php echo e($img->id); ?>">
                                    <label class="form-check-label">
                                        Hapus
                                    </label>
                                </div>

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

                    </div>

                    <h6>Preview Gambar Baru</h6>

                    <div class="row" id="previewContainer"></div>

                    <button class="btn btn-primary mt-3">
                        Update Project
                    </button>
                    <a href="<?php echo e(route('project.index')); ?>" class="btn btn-secondary mt-3">Kembali</a>

                </form>

            </div>
        </div>

    </div>

    <script>
        document.getElementById('gambarInput').addEventListener('change', function(e) {

            let preview = document.getElementById('previewContainer');
            preview.innerHTML = '';

            Array.from(e.target.files).forEach(file => {

                let reader = new FileReader();

                reader.onload = function(e) {

                    let col = document.createElement('div');
                    col.className = "col-md-3 mb-3";

                    col.innerHTML = `
<div class="card">
<img src="${e.target.result}" style="height:150px;object-fit:cover">
</div>
`;

                    preview.appendChild(col);

                }

                reader.readAsDataURL(file);

            });

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

<?php echo $__env->make('app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\PROJECT\profile\resources\views/project/edit.blade.php ENDPATH**/ ?>