[Vuejs]-How to pass value from vue.js to controller?

4👍

You can use vue-resource and send it using post:

new Vue({
    el: '#app',

    data: {
        token: '{{ csrf_token() }}',
        property_credentials: {
            additionals_features: [],
        }
    },

    methods: {
        submit: function() {
            this.$http.post('/your-api-url', {
                '_method': 'patch',
                '_token': this.token, // You must pass this token on post requests
                'additionals_features': this.property_credentials.additionals_features,
            });
        }
    }
});

The data will arrive directly in your controller, so you can probably

$additional_features = $request->get('additionals_features');

What you do with this data once it arrives in the controller, it’s up to you.

Leave a comment