

<?php $__env->startSection('title','Edit Event'); ?>

<?php $__env->startSection('content'); ?>

<div class="container" style="max-width:980px;">
    <div class="card-dark p-4">
        <div class="d-flex flex-column flex-md-row align-items-start align-items-md-center justify-content-between gap-3 mb-3">
            <div>
                <h3 class="mb-1">Edit Event</h3>
                <p class="text-muted-sm">Perbarui data event. Biarkan gambar kosong jika tidak ingin mengganti.</p>
            </div>
            <a href="<?php echo e(route('events.index')); ?>" class="btn btn-outline-soft">Kembali ke daftar</a>
        </div>

        <?php if($errors->any()): ?>
            <div class="alert alert-danger mb-3">
                <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>
            </div>
        <?php endif; ?>

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

            <div class="row g-4">
                <div class="col-lg-8">
                    <div class="mb-3">
                        <label class="form-label">Nama Event</label>
                        <input type="text" name="nama_event" class="form-control-dark form-control" value="<?php echo e(old('nama_event', $event->nama_event)); ?>" required>
                    </div>

                    <div class="row g-3">
                        <div class="col-md-6">
                            <label class="form-label">Kategori</label>
                            <select name="kategori_event_id" class="form-control-dark form-control" required>
                                <option value="">Pilih Kategori</option>
                                <?php $__currentLoopData = $kategori; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($k->id); ?>" <?php echo e(old('kategori_event_id', $event->kategori_id) == $k->id ? 'selected' : ''); ?>><?php echo e($k->nama_kategori); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Lokasi</label>
                            <select name="lokasi_id" class="form-control-dark form-control" required>
                                <option value="">Pilih Lokasi</option>
                                <?php $__currentLoopData = $lokasi; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $l): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($l->id); ?>" <?php echo e(old('lokasi_id', $event->lokasi_id) == $l->id ? 'selected' : ''); ?>><?php echo e($l->nama_lokasi); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>
                    </div>

                    <div class="row g-3 mt-3">
                        <div class="col-md-6">
                            <label class="form-label">Tanggal</label>
                            <input type="date" name="tanggal" class="form-control-dark form-control" value="<?php echo e(old('tanggal', $event->tanggal)); ?>" required>
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">Jam (opsional)</label>
                            <input type="time" name="jam" class="form-control-dark form-control" value="<?php echo e(old('jam', $event->jam)); ?>">
                        </div>
                    </div>

                    <div class="mt-3">
                        <label class="form-label">Deskripsi</label>
                        <textarea name="deskripsi" rows="6" class="form-control-dark form-control" required><?php echo e(old('deskripsi', $event->deskripsi)); ?></textarea>
                    </div>
                </div>

                <div class="col-lg-4">
                    <div class="card-dark p-3 h-100">
                        <label class="form-label">Gambar Saat Ini</label>
                        <div class="mb-3">
                            <img id="preview" src="<?php echo e($event->gambar ? asset('storage/'.$event->gambar) : asset('images/placeholder.svg')); ?>" alt="preview" style="width:100%;height:220px;object-fit:cover;border-radius:14px;">
                        </div>
                        <input type="file" name="gambar" id="gambar" class="form-control-dark form-control">
                        <div class="text-muted small mt-2">Unggah untuk mengganti gambar acara.</div>
                    </div>
                </div>
            </div>

            <div class="mt-4 d-flex flex-wrap gap-2">
                <button class="btn-primary-glow">Perbarui Event</button>
                <a href="<?php echo e(route('events.index')); ?>" class="btn btn-outline-soft">Batal</a>
            </div>
        </form>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
document.getElementById('gambar')?.addEventListener('change', function(e) {
    const file = e.target.files[0];
    if (!file) return;
    document.getElementById('preview').src = URL.createObjectURL(file);
});
</script>
<?php $__env->stopPush(); ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\tugas pa asur\konser-ticket\resources\views/events/edit.blade.php ENDPATH**/ ?>