From the course: Laravel Essential Training

Unlock the full course today

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

Show soft deleted model

Show soft deleted model - Laravel Tutorial

From the course: Laravel Essential Training

Show soft deleted model

We now have the list of trashed items, but if you click on any of the deleted notes, it takes us to the notes route and we get a 404 error because this note is deleted. What we now need is the show route for trashed note and the show method in the controller. Open web.php. And using Route::get, let's add a show route, /trashed/{note}. We need to pass in the note unique ID, and this will call the controller, TrashedNoteController. Show action. Don't show again. And this will also have to go through the auth middleware. And the name would be trashed.show. Yes, but this isn't sufficient. We do not get a soft deleted model while using route model binding by default, right? So you need to chain this with trashed method to include soft deleted models. Right here. Or you can cut this and put it even before the middleware. Yeah. This is perfect. Now open the TrashedNoteController. Add a new show method. Public function show, and accept the note model here. Let's dump and die this note to see…

Contents