[Vuejs]-Laravel, inertiajs and vuejs

0👍

You can pass data to your method like this:

<button @click="deleteUser(user)">Delete</button>

methods: {
deleteUser: function(user){
this.$inertia.delete(this.route('users.destroy'), user))
}}

This is because your delete method in user controller is asking for a user variable.

0👍

The delete action should accept the current user from the iteration as an argument.

<button @click="delete(user)" class="border border-purple-300 px-4 py-1 rounded-full text-purple-600 hover:bg-purple-600 hover:text-white hover:border-transparent">Follow</button>

Then you should pass the user id as a parameter for your delete route:

methods: {
    delete(user) {
        if (confirm('Are you sure you want to delete this contact?')) {
            this.$inertia.delete(`/destroy/${user.id}`);
        }
    }
}

Leave a comment