Understanding saveQuietly() in Laravel: When and How to Use It
When working with Laravel models, there are times when you want to save changes to the database without triggering any events. This is where the saveQuietly() method comes into play. In this article, we'll explore what saveQuietly() is, why you might use it, and provide practical examples of its use.
What is saveQuietly()?
The saveQuietly() method allows you to save a model to the database without firing any model events, such as creating, created, updating, updated, etc. It’s particularly useful when you need to make changes silently without affecting listeners or observers that are watching for model events.
Why Use saveQuietly()?
- Prevent Unwanted Events: Sometimes, you want to update or save a model but avoid triggering events that may perform actions like sending emails or updating other services.
- Efficiency in Bulk Operations: When making bulk changes, suppressing events can improve performance by reducing the overhead caused by multiple listeners or observers.
- Data Migration or Cleanup: When migrating or cleaning up data,
saveQuietly()allows you to modify records without invoking event-driven processes.
Practical Examples of Using saveQuietly()
Updating a User Profile Quietly
Suppose you have an application where updating a user profile triggers a welcome email or a notification. However, during certain admin tasks, you want to update user information without sending notifications:
$user = User::find(1);
$user->email = '[email protected]';
$user->saveQuietly();This method updates the user’s email without triggering the updated event.
Bulk Status Update
If you’re performing a bulk update and don’t want to trigger events for each model, saveQuietly() is ideal:
$orders = Order::where('status', 'pending')->get();
foreach ($orders as $order) {
$order->status = 'completed';
$order->saveQuietly();
}his loop updates the status of each order without firing the updating or updated events.
Conclusion
The saveQuietly() method provides an efficient way to save model changes without triggering events. It’s particularly useful for administrative tasks, bulk updates, and data migration where you want to control or suppress event-driven processes.
Have you used saveQuietly() in your Laravel projects? Share your experiences in the comments below, and subscribe to our newsletter for more tips!
I hope you enjoyed this post. Feel free to clap this article (👏) and subscribe to my Medium newsletter for more.
👋 I offer tech consulting services for companies that need help with their Laravel applications. I can assist with upgrades, refactoring, testing, new features, or building new apps. Feel free to contact me through LinkedIn, or you can find my email on my GitHub profile.





