From the course: Laravel Essential Training

Unlock the full course today

Join today to access over 25,100 courses taught by industry experts.

Restore soft deleted models

Restore soft deleted models - Laravel Tutorial

From the course: Laravel Essential Training

Restore soft deleted models

After viewing the deleted note, the user might wish to either restore this note or delete it permanently. The two buttons we commented out earlier can be modified to display these two options for each trashed note. Here they are. For editing a note, we used a link, but to restore a note, we need a form and a button, just like we did for delete note. So let me uncomment this, remove this, and let me copy this once again. Retain this. So I will comment it out again. I will reuse this form for restoring the note. So the action will be trashed.update because we just have to change the deleted_at column for restoring that note. So trashed.update would be an accurate route. We will be passing the note model. Once again, the method is paused and we can spoof it with put. We can retain the CSRF attribute. And here, we don't need a red color. So let me remove all of this. We can remove the entire class. We can keep the same black color and onclick, you can either keep this or remove it. You…

Contents