How to undelete a soft deleted Eloquent row?

Laravel: How to undelete a soft deleted Eloquent row?

Use the restore() method.

  1. User::withTrashed()->where("id",1)->restore()

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to undelete a soft deleted Eloquent row?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Laravel language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to check if a relation was loaded on an Eloquent model already?

What are Apache MPMs?

What is the null coalescing operator in PHP7?

What are generators in PHP, and how do they compare to arrays?

How to do comments in Blade files?

How to check if a (blade) view file exists

Remove trailing slash (redirect to remove trailing slash) in .htaccess

How to return an item in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

How does PHP compare objects?

How to find the average value of items in a Laravel Collection?