[Vuejs]-How to show data in Vue tab in devtools?

0πŸ‘

βœ…

In your AdvertController.php controller store() method should be responsible to add new record.

You should be using show() method instead.

You can read more about Route::resource() in Resource Controllers

public function show(Request $request, $id)
{
    return Category::find($id);
}

And in your Advert.vue, methods should look like this

<template>
    <div>
        <ul class="list-group">
            <li
              v-for="category in categories"
              @click="sendAdvert(category.id)"
              class="list-group-item display"
            >
              {{ category.name }}
            </li>
        </ul>
    </div>
</template>

<script>
    export default {
        props: ['categories'],
        data() {
            return {
                advert:         [],
            }
        },

        methods: {
            sendAdvert(id) {
                // this will load single advert
                axios.get('/adverts/'+id)
                    .then(response => {
                        this.advert = response.data;
                    });
            }
        }
    }
</script>

Leave a comment