From the course: Building Laravel and Vue.js 2 Web Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Validating form submissions

Validating form submissions

From the course: Building Laravel and Vue.js 2 Web Apps

Start my 1-month free trial

Validating form submissions

- [Narrator] In this video, we'll look at how to add server side validation for Laravel models. So now, we'll finally get around to creating a model and a database table for menu items. In our homestead shell, we'll do artisan make model this will be called menu item and again, the M option to add a migration and R to create a resource controller. So if we open up that migration now we're going to be a little bit more detailed than we were last time with the category table. So I'm going to start with the name and description columns. These will be string columns, or VARCHAR when they're created in MySQL. And this time, we'll give them max lengths. Name 128 and for description (typing) we'll set the max to 512. Next we'll do the price for the menu item this will be a decimal column. And I could do a precision and scale there but if I just use the default this will allow me to use 8 digits total, including 2 decimal places which should be fine for the price of a menu item. Just like…

Contents