From the course: Laravel Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Add a store action to save the data - Laravel Tutorial
From the course: Laravel Essential Training
Add a store action to save the data
Now let's add the required functionality in the store method of our controller to save the note. Let's first die and dump this request here to see what we've got. dd $request. Go to the browser and refresh. Click "Continue". Now expand this request and we have three parameters. Yes, we have the token and our title and text. But before we insert this data into the database, we need to validate them. This can be done using the validate method on the request object. Request validate. And we can pass in the rules here. So the rule for title validation rule would be, you know, probably you can say this is required and it could have a max length of 120 characters or something like this. And then for the text, we can simply have required validation. All the available validation rules can be found in the Laravel documentation right here. So you can take a look at this. All right. If this validation passes, our code will continue executing here normally. But if the validation fails, the user…
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)
-
-
-
-