<?php if (isset($component)) { $__componentOriginalc6e081c8432fe1dd6b4e43af4871c93447ee9b23 = $component; } ?>
<?php $component = $__env->getContainer()->make(App\View\Components\MasterLayout::class, ['assets' => $assets ?? []]); ?>
<?php $component->withName('master-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
    <div>
        <?php $id = $id ?? null;?>
        <?php if(isset($id)): ?>
            <?php echo Form::model($data, ['route' => ['vehicle.update', $id], 'method' => 'patch','enctype' => 'multipart/form-data', 'id' => 'vehicle_form']); ?>

        <?php else: ?>
            <?php echo Form::open(['route' => ['vehicle.store'], 'method' => 'post','enctype' => 'multipart/form-data', 'id' => 'vehicle_form']); ?>

        <?php endif; ?>
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header d-flex justify-content-between">
                        <div class="header-title">
                            <h4 class="card-title"><?php echo e($pageTitle); ?></h4>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="new-user-info">
                            <div class="row">
                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('title',__('message.name').' <span class="text-danger">*</span>',['class'=>'form-control-label'], false )); ?>

                                    <?php echo e(Form::text('title', old('title'),['placeholder' => __('message.name'),'class' =>'form-control'])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('capacity',__('message.vehicle_capacity').' <span class="text-danger">*</span>',['class'=>'form-control-label'], false )); ?>

                                    <?php echo e(Form::text('capacity', old('capacity'),['placeholder' => __('message.vehicle_capacity'),'class' =>'form-control'])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('size',__('message.vehicle_size').' <span class="text-danger">*</span>',['class'=>'form-control-label'], false )); ?>

                                    <?php echo e(Form::text('size', old('size'),['placeholder' => __('message.vehicle_size'),'class' =>'form-control'])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('description',__('message.description').' <span class="text-danger">*</span>',['class'=>'form-control-label'], false )); ?>

                                    <?php echo e(Form::text('description', old('description'),['placeholder' => __('message.description'),'class' =>'form-control'])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('type',__('message.type').' <span class="text-danger">*</span>',['class'=>'form-control-label'],false)); ?>

                                    <?php echo e(Form::select('type',[ 'city_wise' => __('message.city_wise'), 'all' => __('message.all') ], old('type'), [ 'class' =>'form-control select2js','required'])); ?>

                                </div>

                                <div class="form-group col-md-4" id="cityField">
                                    <?php echo e(Form::label('city_ids', __('message.city').' <span class="text-danger">*</span>', [ 'class' => 'form-control-label' ],false)); ?>

                                    <?php echo e(Form::select('city_ids[]', $selected_cities ?? [],  $data->city_ids ?? old('city_ids'), [
                                        'class' => 'select2js form-group city_ids',
                                        'data-placeholder' => __('message.city'),
                                        'multiple' => true,
                                        'data-ajax--url' => route('ajax-list', [ 'type' => 'city-list' ]),
                                    ])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('status',__('message.status').' <span class="text-danger">*</span>',['class'=>'form-control-label'],false)); ?>

                                    <?php echo e(Form::select('status',['1' => __('message.enable'), '0' => __('message.disable') ], old('status'), [ 'class' =>'form-control select2js'])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <?php echo e(Form::label('price', __('message.price').' <span class="text-danger">*</span>',['class' => 'form-control-label'],false )); ?>

                                    <?php echo e(Form::number('price', old('price'),[ 'step' =>'any','min' =>'0', 'placeholder' => __('message.price'), 'class' => 'form-control'])); ?>

                                </div>

                                <div class="form-group col-md-4">
                                    <label class="form-control-label" for="image"><?php echo e(__('message.image')); ?></label>
                                    <div class="custom-file">
								        <?php echo e(Form::file('vehicle_image', [ 'class'=> 'custom-file-input', 'id' => 'vehicle_image', 'data--target' => 'vehicle_image_preview', 'lang' => 'en', 'accept'=> 'image/*' ])); ?>

                                        <label class="custom-file-label"><?php echo e(__('message.choose_file',['file' =>  __('message.image') ])); ?></label>
                                    </div>
                                    <span class="selected_file"></span>
                                </div>
                                <div class="col-md-2 mb-2">
                                    <?php if(isset($id) && getMediaFileExit($data, 'vehicle_image')): ?>
                                        <img id="vehicle_image_preview" src="<?php echo e(getSingleMedia($data, 'vehicle_image'?? 'images/default.png')); ?>" alt="image" class="attachment-image mt-1 vehicle_image_preview">
                                    <?php else: ?>
                                    <img id="vehicle_image_preview" src="<?php echo e(asset('images/default.png')); ?>" alt="image" class="attachment-image mt-1 vehicle_image_preview">
                                    <?php endif; ?>
                                </div>
                            </div>
                            <hr>
                            <?php echo e(Form::submit( isset($id) ? __('message.update') : __('message.save'), ['class'=>'btn btn-md btn-primary float-right'])); ?>

                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php echo Form::close(); ?>

    </div>
    <?php $__env->startSection('bottom_script'); ?>
        <script>
            $(document).ready(function() {
                function toggleCityField() {
                    var typeValue = $('select[name="type"]').val();
                    if (typeValue =='all') {
                        $('#cityField').hide();
                        $('select[name="city_ids[]"]').empty();
                    } else {
                        $('#cityField').show();
                    }
                }
                toggleCityField();

                $('select[name="type"]').change(function () {
                    toggleCityField();
                });
                var isImageUploaded = <?php echo e(isset($id) && getMediaFileExit($data, 'vehicle_image') ? 'true' : 'false'); ?>;
                formValidation("#vehicle_form", {
                    title: { required: true },
                    capacity: { required: true },
                    size: { required: true },
                    description: { required: true },
                    type: { required: true },
                    'city_ids[]': { required: true },
                    status: { required: true },
                    price: { required: true },
                    vehicle_image: { required: !isImageUploaded },
                }, {
                    title: { required: "<?php echo e(__('message.please_enter_title')); ?>" },
                    capacity: { required: "<?php echo e(__('message.please_enter_capacity')); ?>" },
                    size: { required: "<?php echo e(__('message.please_enter_size')); ?>" },
                    description: { required: "<?php echo e(__('message.please_enter_description')); ?>" },
                    type: { required: "<?php echo e(__('message.please_select_type')); ?>" },
                    'city_ids[]': { required: "<?php echo e(__('message.please_select_city')); ?>" },
                    status: { required: "<?php echo e(__('message.please_select_status')); ?>" },
                    price: { required: "<?php echo e(__('message.please_enter_price')); ?>" },
                    vehicle_image: { required: "<?php echo e(__('message.please_image_select')); ?>" },
                });
            });
        </script>
    <?php $__env->stopSection(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc6e081c8432fe1dd6b4e43af4871c93447ee9b23)): ?>
<?php $component = $__componentOriginalc6e081c8432fe1dd6b4e43af4871c93447ee9b23; ?>
<?php unset($__componentOriginalc6e081c8432fe1dd6b4e43af4871c93447ee9b23); ?>
<?php endif; ?>
<?php /**PATH /www/wwwroot/mxunzo.mimeld.com/resources/views/vehicle/form.blade.php ENDPATH**/ ?>