From the course: Laravel Essential Training

Unlock the full course today

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

Solution: Add index and create methods for a new resource

Solution: Add index and create methods for a new resource - Laravel Tutorial

From the course: Laravel Essential Training

Solution: Add index and create methods for a new resource

Let's start adding functionality to the index action of the NotebookController. We can copy this from the index action of the NoteController. So open NoteController. Copy this and paste it here. Change all the instances of note to notebook and import auth. And here, we don't need pagination, so you can replace this with get. And this would be notebooks. return view('notebooks.index') ->with('notebooks', $notebooks); All right. And while we are at the controller, let's also edit the create and store method. In the create method, you simply return a view which could be notebooks.create. And in the store method, once again we can copy this from the NoteController's store method. Copy all of this and paste it here. Replace the title with name instead and let the rules simply be required. Remove text, and new notebook would be new Notebook, and you can remove the uuid, you can remove the text. You can replace title with name. This would be $notebook->save(); And once it's saved, let's…

Contents