Skip to content
Advertisement

Laravel 8: Method IlluminateDatabaseEloquentCollection::update does not exist ERROR

I want to update some data from the DB, so I added this Controller method:

JavaScript

Now the problem is I get this error:

JavaScript

So how to solve this issue?

Advertisement

Answer

You are already resolving $anss using route-model binding.

JavaScript

You are trying to call findOrFail with a model as an argument, which since Model implements Arrayable will return a Collection, thus breaking the update call.

See IlluminateDatabaseEloquentBuilder findOrFail -> find -> findMany -> return $this->whereKey($ids)->get($columns);.

Try:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement