0👍
✅
First of all, you have to pass both department
and user
in the click event:
<div class="btn btn-danger btn-sm" @click="removeUser(department, user)">
<i class="fa fa-trash"></i>
</div>
Then, in the removeUser
method:
removeUser(department, user){
axios.delete(`/api/users/${user.id}/delete`).then(response => {
const index = this.personnal[department].findIndex(u => u.id === user.id);
this.personnal[department].splice(index, 1);
});
}
Source:stackexchange.com