<?php if(isset($attribute)): ?>
    <address-component
        :attribute='<?php echo json_encode($attribute, 15, 512) ?>'
        :validations="'<?php echo e($validations); ?>'"
        :data='<?php echo json_encode(old($attribute->code) ?: $value, 15, 512) ?>'
    ></address-component>
<?php endif; ?>

<?php $__env->startPush('scripts'); ?>

    <script type="text/x-template" id="address-component-template">
        <div class="form-group" :class="[errors.has(attribute['code'] + '[address]') || errors.has(attribute['code'] + '[country]') || errors.has(attribute['code'] + '[state]') || errors.has(attribute['code'] + '[city]') || errors.has(attribute['code'] + '[postcode]') ? 'has-error' : '']">
            <div class="address-left">
                <textarea
                    :name="attribute['code'] + '[address]'"
                    class="control"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.address')); ?>&quot;"
                >{{ data ? data['address'] : '' }}</textarea>
            </div>
    
            <div class="address-right">

                <select
                    :name="attribute['code'] + '[country]'"
                    class="control"
                    v-model="country"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.country')); ?>&quot;"
                >
                    <option value=""><?php echo e(__('admin::app.common.select-country')); ?></option>

                    <?php $__currentLoopData = core()->countries(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $country): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                        <option value="<?php echo e($country->code); ?>"><?php echo e($country->name); ?></option>

                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>

                <select
                    :name="attribute['code'] + '[state]'"
                    class="control"
                    v-model="state"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.state')); ?>&quot;"
                    v-if="haveStates()"
                >

                    <option value=""><?php echo e(__('admin::app.common.select-state')); ?></option>

                    <option v-for='(state, index) in countryStates[country]' :value="state.code">
                        {{ state.name }}
                    </option>

                </select>

                <input
                    type="text"
                    :name="attribute['code'] + '[state]'"
                    class="control"
                    v-model="state"
                    placeholder="<?php echo e(__('admin::app.common.state')); ?>"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.state')); ?>&quot;"
                    v-else
                />

                
                <input
                    type="text"
                    :name="attribute['code'] + '[city]'"
                    class="control"
                    :value="data['city']"
                    placeholder="<?php echo e(__('admin::app.common.city')); ?>"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.city')); ?>&quot;"
                    v-if="data && data['city']"
                />

                <input
                    type="text"
                    :name="attribute['code'] + '[city]'"
                    class="control"
                    placeholder="<?php echo e(__('admin::app.common.city')); ?>"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.city')); ?>&quot;"
                    v-else
                />
                
                <input
                    type="text"
                    :name="attribute['code'] + '[postcode]'"
                    class="control"
                    :value="data['postcode']"
                    placeholder="<?php echo e(__('admin::app.common.postcode')); ?>"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.postcode')); ?>&quot;"
                    v-if="data && data['postcode']"
                />

                <input
                    type="text"
                    :name="attribute['code'] + '[postcode]'"
                    class="control"
                    placeholder="<?php echo e(__('admin::app.common.postcode')); ?>"
                    v-validate="validations"
                    data-vv-as="&quot;<?php echo e(__('admin::app.common.postcode')); ?>&quot;"
                    v-else
                />
            </div>

            <span class="control-error" v-if="errors.has(attribute['code'] + '[address]') || errors.has(attribute['code'] + '[country]') || errors.has(attribute['code'] + '[state]') || errors.has(attribute['code'] + '[city]') || errors.has(attribute['code'] + '[postcode]')">
                <?php echo e(__('admin::app.common.address-validation')); ?>

            </span>
        </div>
    </script>

    <script>
        Vue.component('address-component', {

            template: '#address-component-template',
    
            props: ['validations', 'attribute', 'data'],

            inject: ['$validator'],

            data: function () {
                return {
                    country: this.data ? this.data['country'] : '',

                    state: this.data ? this.data['state'] : '',

                    countryStates: <?php echo json_encode(core()->groupedStatesByCountries(), 15, 512) ?>
                }
            },

            methods: {
                haveStates: function () {
                    if (this.countryStates[this.country] && this.countryStates[this.country].length) {
                        return true;
                    }

                    return false;
                },
            }
        });
    </script>
<?php $__env->stopPush(); ?><?php /**PATH /home/quikappspane/public_html/cmr.quik-apps.com.co/laravel-crm/packages/Webkul/Admin/src/Providers/../Resources/views/common/custom-attributes/edit/address.blade.php ENDPATH**/ ?>