
<?php $__env->startSection('title', 'Add Airline Company'); ?>
<?php $__env->startPush('style'); ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Dropify/0.2.2/css/dropify.min.css" />
<style>
    .dropify-wrapper {
        border-radius: 5px;
        border: 1px dashed #3b71ca;
    }

    .dropify-wrapper .dropify-message p {
        font-weight: 500;
        color: #3b71ca;
    }

    .dropify-wrapper .dropify-message span.file-icon {
        color: #3b71ca;
    }

    .invalid-feedback {
        display: block;
        font-weight: 500;
    }

</style>
<?php $__env->stopPush(); ?>
<?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"><i class='bx bx-plus'></i> Add Airline Company</h4>
                        </div>
                        <div>
                            <a href="<?php echo e(route('airline.company.index')); ?>" class="btn btn-primary btn-sm" title="List">
                                <span class="btn-label">
                                    <i class="fas fa-building"></i>
                                </span>
                                Airline Company 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="airlineCompanyForm" action="<?php echo e(route('airline.company.store')); ?>" method="POST" enctype="multipart/form-data">
                            <?php echo csrf_field(); ?>
                            <div class="row mb-3">
                                <div class="col-lg-3">
                                    <input type="file" name="logo" class="dropify" accept="image/*" required>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-md-6">
                                    <label>Airline Company Name</label>
                                    <input type="text" name="name" class="form-control" value="<?php echo e(old('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">Save Airline Company</span>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('script'); ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Dropify/0.2.2/js/dropify.min.js"></script>
<script>
    $(document).ready(function() {
        $('.dropify').dropify({
            messages: {
                'default': 'Drag and drop or click to upload'
                , 'replace': 'Drag and drop or click to replace'
                , 'remove': 'Remove'
                , 'error': 'Oops, something went wrong.'
            }
        , });
    });
</script>
<script>
$('#airlineCompanyForm').on('submit', function (e) {
    e.preventDefault();

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

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

    $.ajax({
        url: $(form).attr('action'),
        method: 'POST',
        data: formData,
        processData: false,   // important for file upload
        contentType: false,   // important for file upload
        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: '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 /home/u973467024/domains/mhjohn.xyz/public_html/view-trip/resources/views/backend/airline-company/show.blade.php ENDPATH**/ ?>