1. Home
  2. Laravel
  3. Basic
  4. 6.Laravel ই-কমার্স: Product Catalog System – বাংলায় ধাপে ধাপে

6.Laravel ই-কমার্স: Product Catalog System – বাংলায় ধাপে ধাপে

অসাধারণ! তুমি চাইছো আমি একদম প্রথম থেকে প্রতিটি মডেল ও মাইগ্রেশন step-by-step করে দেখাই, যাতে তুমি প্রতিটি অংশ আলাদাভাবে তৈরি করে বুঝে নিতে পারো — এবং প্রতিটি মডেলের migration করার পরেই php artisan migrate চালিয়ে টেবিলটি ডেটাবেইসে তৈরি করো।

তাহলে চল, আমরা Laravel Product Catalog System শুরু করি সম্পূর্ণ প্রফেশনাল ও পরিষ্কারভাবে:


🧱 Step-by-Step: Laravel Product Catalog System

(Model → Migration → Migrate একটার পর একটা)


✅ Step 1: Category

➤ মডেল + মাইগ্রেশন তৈরি:

php artisan make:model Category -m

database/migrations/xxxx_create_categories_table.php:

public function up()
{
    Schema::create('categories', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->string('slug')->unique();
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 2: Brand

➤ মডেল + মাইগ্রেশন:

php artisan make:model Brand -m

create_brands_table.php:

public function up()
{
    Schema::create('brands', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->string('slug')->unique();
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 3: Tag

➤ মডেল + মাইগ্রেশন:

php artisan make:model Tag -m

create_tags_table.php:

public function up()
{
    Schema::create('tags', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->string('slug')->unique();
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 4: Product

➤ মডেল + মাইগ্রেশন:

php artisan make:model Product -m

create_products_table.php:

public function up()
{
    Schema::create('products', function (Blueprint $table) {
        $table->id();
        $table->foreignId('category_id')->constrained()->onDelete('cascade');
        $table->foreignId('brand_id')->constrained()->onDelete('cascade');
        $table->string('name');
        $table->string('slug')->unique();
        $table->text('description')->nullable();
        $table->decimal('price', 10, 2);
        $table->boolean('is_featured')->default(false);
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 5: product_tag (Pivot Table)

➤ মাইগ্রেশন:

php artisan make:migration create_product_tag_table

create_product_tag_table.php:

public function up()
{
    Schema::create('product_tag', function (Blueprint $table) {
        $table->id();
        $table->foreignId('product_id')->constrained()->onDelete('cascade');
        $table->foreignId('tag_id')->constrained()->onDelete('cascade');
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 6: ProductImage

➤ মডেল + মাইগ্রেশন:

php artisan make:model ProductImage -m

create_product_images_table.php:

public function up()
{
    Schema::create('product_images', function (Blueprint $table) {
        $table->id();
        $table->foreignId('product_id')->constrained()->onDelete('cascade');
        $table->string('image_path');
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 7: Variant

➤ মডেল + মাইগ্রেশন:

php artisan make:model Variant -m

create_variants_table.php:

public function up()
{
    Schema::create('variants', function (Blueprint $table) {
        $table->id();
        $table->foreignId('product_id')->constrained()->onDelete('cascade');
        $table->string('size')->nullable();
        $table->string('color')->nullable();
        $table->integer('stock')->default(0);
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

✅ Step 8: Attribute

➤ মডেল + মাইগ্রেশন:

php artisan make:model Attribute -m

create_attributes_table.php:

public function up()
{
    Schema::create('attributes', function (Blueprint $table) {
        $table->id();
        $table->foreignId('product_id')->constrained()->onDelete('cascade');
        $table->string('key');
        $table->string('value');
        $table->timestamps();
    });
}

➤ মাইগ্রেশন চালাও:

php artisan migrate

📌 উপসংহার:

এখন তুমি সফলভাবে নিচের টেবিলগুলো Laravel এ তৈরি করে ফেলেছো:

টেবিলDescription
categoriesপ্রোডাক্টের ক্যাটেগরি
brandsব্র্যান্ড ইনফরমেশন
tagsট্যাগ সিস্টেম
productsপ্রোডাক্ট ডেটা
product_tagপ্রোডাক্ট ও ট্যাগের many-to-many সম্পর্ক
product_imagesমাল্টিপল ইমেজ
variantsকালার-সাইজ ভিত্তিক স্টক
attributesকাস্টম প্রোডাক্ট অ্যাট্রিবিউট

🔜 পরবর্তী পরামর্শ:

তুমি এখন চাইলে:

  1. Eloquent Relationship define করতে পারো
  2. Seeder দিয়ে ডেমো ডেটা ঢোকাতে পারো
  3. Filament Admin Panel দিয়ে CRUD তৈরি করতে পারো
  4. Tailwind CSS দিয়ে Product Grid ডিজাইন করতে পারো

🔔 তুমি কোনটা আগে করতে চাও? বললেই আমি বাংলায় টিউটোরিয়াল করে দিচ্ছি।

Articles

How can we help?