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

Unlock the full course today

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

Creating a model and seeding the database

Creating a model and seeding the database

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

Start my 1-month free trial

Creating a model and seeding the database

- [Instructor] The first thing we'll do with our new homepage is change this section so that the category names and image file names are pulled from the database. So, switch to your homestead shell if you're not there already, by using this dropdown. And we'll use artisan to create a model called category, so artisan make:model Category. And then, with the M and R options, we can also generate at the same time a migration for creating category table in the database and a resource controller with some basic CRUD actions. So, in my app folder now, I have this category model, and it doesn't need anything else for now except what's provided in the base model class. And in HTTP controllers, in my category controller, I won't use all of these methods, but it's nice to have this shell as a starting point. And then in database migrations, I have this new migration file. And here I'm going to add name and image columns for the category table. So these will be string or a VARCHAR in MySQL, and…

Contents