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 redirect your website to a new domain/location in .htaccess

How to split a string into an array, in JS

Why should you update APP_URL from from http://localhost?

How to get the first row that matches some where queries, or create it if it doesn't exist (in Laravel's Eloquent)?

How to set custom HTTP headers in Apache (by editing .htaccess)

How to remove .php from the end of URLs with .htaccess

What does PEAR stand for?

How to install and use optipng on Linux CentOS

How to provide a default model object for relationships?

How to set up an alias to map one directory to another destination