🔴 Laravel Intermediate

What is the difference between update() and save() in Eloquent?

Why Interviewers Ask This

This question targets practical, hands-on experience with Laravel. Interviewers want to see if you've worked with these concepts in real projects, not just read about them. Strong answers include concrete examples.

Answer

Both persist model data but work differently. save() is an instance method — call it on a model object to either INSERT (if new) or UPDATE (if the model has a primary key). It fires creating/created events for new models and updating/updated events for existing ones. $user = User::find(1); $user->name = "Alice"; $user->save(). update() is a mass-update method that can be called on a query builder or a model instance: User::where("active", false)->update(["banned" => true]) — updates all matching rows with a single SQL UPDATE. On an instance: $user->update(["name" => "Alice"]) is a shortcut for fill+save. Key difference: query builder update() does NOT fire Eloquent model events or run model observers — it goes directly to the database. Use save() when you need events and observers to fire; use query builder update() for bulk updates.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Laravel answers easy to follow.