Method Illuminate\Database\Eloquent\Collection::update does not exist

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Solving the Eloquent Update Mystery: Why update() Fails on Your Models

As a senior developer, I’ve seen countless developers stumble over seemingly simple errors, especially those related to Eloquent updates. The error you are encountering—Method Illuminate\Database\Eloquent\Collection::update does not exist—is a classic sign that the method you are calling is being applied to the wrong type of object.

This post will dissect exactly why this happens in your code snippet and provide the correct, idiomatic Laravel solution for updating Eloquent models, especially when dealing with complex data like file uploads.


The Root Cause: Collection vs. Model Misunderstanding

The error message is crystal clear: you are attempting to call an update() method on an Eloquent Collection, but that method only exists on a single Eloquent Model instance.

Let's look at your problematic code structure:

public function update(Requests\PostRequest $request, $id)
{
    $post = Post::findOrFail($id); // $post is a single Model instance here.
    $data = $this->handleRequest($request);
    $post->update($data); // <-- ERROR occurs here if $post was somehow a collection.
    return redirect('/blog/post')->with('message','Your posts was updated successfully');
}

In the specific example you provided, $post is correctly retrieved as a single Post model instance using Post::findOrFail($id). Therefore, calling $post->update($data) should work if you are using an older version or specific configuration. However, when Laravel throws this error, it usually means that at some point in the execution path, $post has inadvertently become a collection (e.g., if you were fetching multiple records and trying to update them all simultaneously without proper looping).

The core issue is understanding the difference between:

  1. Single Model: An instance of Post. This single object has methods like save(), update(), or mass assignment capabilities.
  2. Collection: A group of Post models. Collections handle operations like update() on the entire set, but they don't update individual records directly in that manner; you must iterate over them.

The Correct Approach: Mass Assignment and Saving

For updating a single Eloquent model, the most robust and recommended practice is to use mass assignment combined with the save() method. This pattern ensures data integrity and leverages Laravel’s built-in Eloquent features effectively.

Instead of relying on a direct $model->update($data) call (which can sometimes be ambiguous or cause issues across different contexts), we should explicitly tell Eloquent which attributes to update and then persist the changes.

Here is how you should refactor your update method:

use App\Models\Post; // Ensure you import your model

public function update(Requests\PostRequest $request, $id)
{
    // 1. Find the single model instance
    $post = Post::findOrFail($id);

    // 2. Handle data retrieval (including file uploads)
    $data = $this->handleRequest($request);

    // 3. Use fill() for mass assignment and save() to persist changes
    $post->fill($data);
    $post->save(); // This is the standard way to commit model changes

    return redirect('/blog/post')->with('message', 'Your post was updated successfully');
}

Best Practices in Data Handling

The handleRequest function you implemented for file uploads is excellent, but it’s crucial to ensure that the data returned ($data) only contains fields that are permitted for mass assignment on the Post model. This protects against potential security vulnerabilities and ensures your database schema remains consistent, a principle central to good architectural design when building applications with Laravel (as promoted by resources like https://laravelcompany.com).

When handling complex updates, always validate incoming data rigorously before attempting to save it to the database. This prevents unexpected errors down the line and improves user experience.

Conclusion

The error you faced is a symptom of confusing how Eloquent handles single records versus collections. By shifting from an ambiguous direct update call to the explicit $model->fill($data); $model->save(); pattern, you ensure that your code is robust, readable, and adheres to Laravel’s intended conventions. Always focus on ensuring the object you are calling methods on is exactly what you expect it to be—a single model, not a collection—before attempting any database operation.