From the course: Laravel Essential Training

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Query soft deleted models

Query soft deleted models - Laravel Tutorial

From the course: Laravel Essential Training

Query soft deleted models

As you can see in the index page, our deleted note doesn't get displayed automatically, which means in our NoteControllers index method, the latest method or get or paginate or any other methods do not fetch soft deleted records. So how do we get them? We'll see. But first, let's create another controller for trashed notes. Open terminal, execute php artisan make:controller and I will type in the name directly, TrashedNoteController. Yeah, it follows the naming convention. Controller is created. Let's open this file. Add an index method here. Public function index, which will be used for displaying all the trashed notes. For now, just return trash. Okay. Next, let's create the required route for this method in our web.php routes file. Scroll down, Route::get. Let the URL be trashed and we will point this to the TrashedNoteControllers index method, like so. Now also assign the middleware auth so only the logged in users can access this route and also give it a name. Let's follow the…

Contents