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.
- [Vuejs]-Vuejs best practices for defence against interface attacks from editing state variables in browser
- [Vuejs]-Bootstrap Vue and Axios
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}`);
}
}
}
Source:stackexchange.com