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

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