#15 Make E-commerce website in Laravel 5.6 | #26 Admin Panel | Products Attributes

Опубликовано: 27 Июль 2026
на канале: Stack Developers
9,743
69

Previous Video | Ecom Part 14:    • #14 Make E-commerce website in Laravel 5.6...  

In Part 15, we will start working on products attributes.

Product attributes we refer to sizes, stock, prices and sku for the product.

SKU stands for Stock Keeping Unit

Suppose we have Test Product with Product code TP01 then it can have following attributes:

SKU Size Price Stock
TP01-S Small 1000 10
TP01-M Medium 1100 15
TP01-L Large 1200 10

All these attributes we need to store in products_attributes table.

So in products_attributes table, we need columns like id, product_id, sku, size, price, stock, created_at and updated_at.

We will use migration to create products_attributes table.

Products table stores all the main product information and main price for the product that we will display at listing page but in detail page price comes from attributes table according to size.

Price may wary according to Size and all such attributes we will store in products_attributes table. So lets start creating table first.

1) Create products_attributes table (With Migration)

Run below command to create migration file :-

php artisan make:migration create_products_attributes_table

Open this file and add all columns that we want in table.

We will add id, product_id, sku, size, price, stock, created_at, updated_at columns

And now run below command to create table:

php artisan migrate.

See now in video, our products_attributes table has been created.

2) Create Model

Now we will create model for products_attributes table like below:

php artisan make:model ProductsAttribute

3) Create Route

Now we will create Route for add-attributes with GET/POST method and pass Product Id.

Route::match(['get','post'],'admin/add-attributes/{id}','ProductsController@addAttributes');

4) Create Function

Now we will create addAttributes function in ProductsController and will also get product id as parameter and will return to add_attributes blade file.

5) Create Blade file

We need to create add_attributes blade file under views/admin/products folder

And then we will add admin design to it. We can copy layout from add products blade file.

Check in video, Add Products Attributes blade file is opening now but nothing there for now.

In the next video, we are going to add Product Attributes form to add sku, sizes, prices and stock.

So Stay tune for the next video..

Thanks for watching...

Next Video | Ecom Part 16:    • #16 Make E-commerce website in Laravel 5.6...