In the previous tutorial we laid down the ground work to allow the shop administrator to add new products, set categories and brands and in this tutor

Laravel Ecommerce Tutorial: Part 6.1, Creating Products

submited by
Style Pass
2023-05-30 09:30:04

In the previous tutorial we laid down the ground work to allow the shop administrator to add new products, set categories and brands and in this tutorial, we will add the ability to manage products in the ecommerce site. This part of the series will be split in parts as well, with this part only focusing on creating products, the next tutorial will continue the from there

We will start by creating the product models and everything else like attributes and variations will follow after this. To create the product models use the following artisan command

Next, let's generate the controller for this model, like always we will be using resourceful controllers, because they are cool!

After the database is migrated let's continue to configure our product model, first mass assignment, I prefer the guarded route because it's clean and minimalistic, however you are welcome to use the fillable method

Now let's add some relationships, we know that a product belongs to a category and a category has many products. We have a one to many relationship.

Leave a Comment