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 - 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
-
-
-
-
-
-
(Locked)
Add an index method to fetch all notes5m 19s
-
(Locked)
Create an index view to display all notes5m 31s
-
(Locked)
Add pagination and clean up the index view4m 53s
-
(Locked)
Add a create method and view to show a form9m 42s
-
(Locked)
Add a store action to save the data7m 21s
-
(Locked)
Add a show action and view to display single note6m 40s
-
(Locked)
Create a unique ID for each note3m 50s
-
(Locked)
Challenge: Add index and create methods for a new resource53s
-
(Locked)
Solution: Add index and create methods for a new resource4m 46s
-
(Locked)
-
-
-
-