0
You have never defined your $customer
variable in your controller’s action.
You can make use of Laravel’s Route Model Binding by updating your controller method’s signature from:
public function update(Request $request, $id)
To:
public function update(Request $request, Customer $customer)
Replace Customer
by your model class.
You can read more about route model binding here: https://laravel.com/docs/5.8/routing#route-model-binding
0
Since you are already passing the ID in the method, why don’t you use that one:
updateName(id) {
axios.post("/customers/" + id, {
name: this.name,
_method: "patch"
})
.then(response => {
console.log(response);
})
.catch(e => {
console.log(e);
});
},
Because as far as I can see your items
is an array, on which you add an object items.data
so it might be that you need to access it using a key this.items[0].data.id
or something like that.
Or just use console.log
and check what does this.items
returns before the axios request.
Source:stackexchange.com