
<?php $__env->startSection('title', 'Update Airport'); ?>
<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="page-inner">
        <div class="row">
            <div class="col-md-12">
                <div class="card card-round">
                    <div class="card-header project-details-card-header py-2 d-flex align-items-center justify-content-between">
                        <div>
                            <h4 class="project-details-card-header-title mb-0"> Update Airport</h4>
                        </div>
                        <div>
                            <a href="<?php echo e(route('airport.index')); ?>" class="btn btn-primary btn-sm" title="List">
                                <span class="btn-label">
                                    <i class="fas fa-users"></i>
                                </span>
                                Airport List
                            </a>
                            <button class="btn btn-black btn-sm" title="Go Back" onclick="history.back();">
                                <span class="btn-label">
                                    <i class="fas fa-reply"></i>
                                </span>
                                Go Back
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <form id="airportForm" action="<?php echo e(route('airport.update', $airport->id)); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <div class="row mb-3">
                                <div class="col-md-12">
                                    <label>Airport Name</label>
                                    <input type="text" name="name" class="form-control" value="<?php echo e(old('name',$airport->name)); ?>" required>
                                    <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <small class="text-danger"><?php echo e($message); ?></small> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="col-12 text-end mt-3">
                                <button type="submit" id="saveBtn" class="btn btn-info">
                                    <i class="fas fa-save me-1"></i>
                                    <span class="btn-text">Update Airport</span>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('script'); ?>
<script>
$('#airportForm').on('submit', function (e) {
    e.preventDefault();

    let form = this;
    let formData = new FormData(form);

    Swal.fire({
        title: 'Updating Airport',
        text: 'Please wait...',
        allowOutsideClick: false,
        didOpen: () => {
            Swal.showLoading();
        }
    });

    $.ajax({
        url: $(form).attr('action'),
        method: 'POST',
        data: formData,
        processData: false,
        contentType: false,
        headers: {
            'X-CSRF-TOKEN': $('input[name="_token"]').val(),
            'Accept': 'application/json'
        },
        success: function (response) {
            Swal.fire({
                icon: 'success',
                title: 'Success',
                text: response.message,
                timer: 1800,
                showConfirmButton: false
            }).then(() => {
                if (response.redirect) {
                    window.location.href = response.redirect;
                }
            });
        },
        error: function (xhr) {
            let msg = 'Something went wrong';

            if (xhr.status === 422) {
                let errors = xhr.responseJSON.errors;
                msg = Object.values(errors).map(e => e[0]).join('\n');
            }

            Swal.fire({
                icon: 'error',
                title: 'Validation Error',
                text: msg
            });
        }
    });
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('backend.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\xampp\htdocs\view-trip-update\resources\views/backend/airport/edit.blade.php ENDPATH**/ ?>