Part 12 - Inserting Data and Validating [How to Build a Blog with Laravel 5 Series]

125 views

0   0


This video is all about storing our data. This will mark the first time we have actually sent information over to the database to be stored for later use. But don’t worry it’s easy!

When creating our store() action we generally follow these steps

1. Validate the data
2. Store it in database
3. Redirect to either show() or index()

Validation is super easy in Laravel 5. We simply need to use the validate function. Link below to see all of the validation rules available to us.

With Laravel 5.2 validation we can simply pass in the rules and Laravel handles the rest. It will automatically redirect us back to the previous page with errors in the session flash (something we learn about in part 13).

We can safely write code under the validate() method and know that all data has passed validation. To enter something in our database we simply create a new Post object and then add the data into that object and finally submit it to the database with the save() method on that object.

--- MORE FROM THIS SERIES ---

Previous Video [Part 11]: https://youtu.be/El4yziFuygQ
Next (optional) video [Part 12 ½]: https://youtu.be/JmvHTg0sy6o
Next Video [Part 13]: coming soon

Full Playlist for the "How to Build a Blog with Laravel" Series: https://www.youtube.com/playlist?list...

--- LINKS ---

Laravel Documentation for Validations: https://laravel.com/docs/master/valid...


--- FOLLOW ME ---

Twitter - http://twitter.com/_jacurtis

---

Tags: Laravel 5 Framework Tutorial Easy to learn. Best tut about Laravel. Blade and validations on the server side. Laravel 5.2 and database mysql. Insert into database with PHP framework. Build a blog with Laravel Tutorial. Beginner tutorial. How to video. PHP framework easy best tutorial.

Published 7 months ago

Category Video  /  Video aulas

Tagsphp laravel mysql database tutorial code how to blade

View More
Comments

0 Comments