

<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12">
        <div>
            <div class="d-flex justify-content-between align-items-center">
                <div class="mb-2 mb-lg-0">
                    <h3 class="mb-0  text-white">About Edit</h3>
                </div>
                <div>
                    <nav aria-label="breadcrumb text-white">
                        <ol class="breadcrumb">
                          <li class="breadcrumb-item"><a class="text-white text-decoration-none" href="<?php echo e(route('about-us.index')); ?>">About List</a></li>
            
                          <li class="breadcrumb-item text-white active" aria-current="page">Edit </li>
                        </ol>
                      </nav>
                </div>
            </div>
        </div>
    </div>
    <div class="col-12">
        <div class="card p-3 bg-white">
            <form  action="<?php echo e(route('about-us.update', $group->id)); ?>" method="POST" enctype="multipart/form-data">
                <?php echo csrf_field(); ?>
                <?php echo method_field('PUT'); ?>
            
                <div id="dynamic-rows">
                    <?php $__currentLoopData = $group->aboutUsEntries; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $entry): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="row mb-3 dynamic-row">
                        <input type="hidden" name="entry_ids[]" value="<?php echo e($entry->id); ?>">
                        
                        <div class="col-lg-12">
                            <label class="form-label">Title</label>
                            <input type="text" name="title[]" class="form-control" value="<?php echo e($entry->title); ?>" required>
                        </div>
                        <div class="col-lg-12">
                            <label class="form-label">Description</label>
                            <textarea name="description[]" class="form-control" required><?php echo e($entry->description); ?></textarea>
                        </div>
                        <div class="col-lg-12">
                            <label class="form-label">Image</label>
                            <input type="file" name="image[]" class="form-control">
                            <?php if($entry->image): ?>
                                <img src="<?php echo e(asset($entry->image)); ?>" alt="Image" width="100" class="mt-2">
                            <?php endif; ?>
                        </div>
                        <div class="col-12 mt-2">
                            <button type="button" class="btn btn-danger remove-row">Remove</button>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            
                <button type="button" id="add-row" class="btn btn-primary mb-3">+ Add Row</button>
                <button type="submit" class="btn btn-success">Update</button>
            </form>
            
        </div>
       
    </div>
</div>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        const dynamicRows = document.getElementById("dynamic-rows");
        const addRowBtn = document.getElementById("add-row");

        // Handle Add Row
        addRowBtn.addEventListener("click", function () {
            const newRow = document.createElement("div");
            newRow.classList.add("row", "mb-3", "dynamic-row");
            newRow.innerHTML = `
                <div class="col-lg-12">
                    <label class="form-label">Title</label>
                    <input type="text" name="title[]" class="form-control" required>
                </div>
                <div class="col-lg-12">
                    <label class="form-label">Description</label>
                    <textarea name="description[]" class="form-control" required></textarea>
                </div>
                <div class="col-lg-12">
                    <label class="form-label">Image</label>
                    <input type="file" name="image[]" class="form-control">
                </div>
                <div class="col-12 mt-2">
                    <button type="button" class="btn btn-danger remove-row">Remove</button>
                </div>
            `;
            dynamicRows.appendChild(newRow);
        });

        // Handle Remove Row (using event delegation)
        dynamicRows.addEventListener("click", function (e) {
            if (e.target && e.target.classList.contains("remove-row")) {
                e.target.closest(".dynamic-row").remove();
            }
        });
    });
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.admin-dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home2/pataneye/public_html/resources/views/admin/pages/about-us/edit.blade.php ENDPATH**/ ?>