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 review blog posts (written by other users) before they get published on your WordPress blog?

What does 'final class' and 'final function' (final method) mean in PHP?

How to find out what version of Laravel you are using?

How to query mysql using PDO in PHP?

How to select all rows for a certain month (or day, year or time), using Eloquent

What is the difference between empty(), isset(), != null, is_null() in PHP

301 Redirect a single URL in .htaccess to a new location

How to install and use jpegoptim on Linux CentOS

How to eager load multiple levels of relationships in Eloquent?

How to replace values in a string, in JS