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
From the course: Building Laravel and Vue.js 2 Web Apps
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Integrating a layout6m 46s
-
(Locked)
Creating a model and seeding the database4m 46s
-
(Locked)
Building views with Blade templates5m 6s
-
(Locked)
Injecting props in Vue components4m 49s
-
(Locked)
Building a CRUD component5m 9s
-
(Locked)
Managing scrolling and focus4m 18s
-
(Locked)
Protecting routes and models with policies5m 5s
-
(Locked)
Building an API with Laravel Passport5m 1s
-
(Locked)
Calling an API from Vue7m 46s
-
-
-
-