Laravel’s Secret Method: createOrRestore()
createOrRestore() is like a supercharged version of firstOrCreate() — but it also restores soft deleted records if they match your attributes.

Laravel has tons of hidden treasures — and one of them is the undocumented but powerful createOrRestore()
method.
While it’s not mentioned in the official docs, this method silently exists in Laravel’s core and can save you time and code when working with soft deleted records.
⚡ What Does It Do?
createOrRestore()
is like a supercharged version of firstOrCreate()
— but it also restores soft deleted records if they match your attributes.
🔥 Why It's Awesome
Automatically restores trashed records if they exist.
Creates new records if no match is found.
Avoids duplicate entries from soft deletes.
Saves you from manual restore logic.
✅ Example Usage
This one-liner will:
Restore the soft deleted user with that email, or
Create a brand new one if it doesn’t exist.
📎 Pro Tip: Use With Caution
Because it’s undocumented, there's no guarantee it won’t be changed or removed in future Laravel versions. But as of now, it’s a slick trick for Laravel pros.
Final Thought
Laravel is full of hidden features that make development easier and cleaner. createOrRestore()
is a perfect example of a “secret” method that can simplify your logic and make your codebase cleaner — especially when dealing with soft deletes.
Try it in your next Laravel project and impress your teammates with your “insider knowledge”! 😎