feat: implement product creation workflow with variants, attribute definitions, and validation logic

This commit is contained in:
2026-06-29 11:02:04 -03:00
parent 9d3ed17c00
commit 18504594eb
23 changed files with 774 additions and 146 deletions

View File

@@ -0,0 +1,50 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// 1. Rename table productos_attributes to attribute
Schema::rename('productos_attributes', 'attribute');
// 2. Rename table productos_variantes_definiciones to productos_variantes_values
Schema::rename('productos_variantes_definiciones', 'productos_variantes_values');
// 3. Create products_attributes intermediate table
Schema::create('products_attributes', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('product_id');
$table->unsignedBigInteger('attribute_id');
$table->timestamps();
$table->foreign('product_id')
->references('id')
->on('productos')
->cascadeOnDelete();
$table->foreign('attribute_id')
->references('id')
->on('attribute')
->cascadeOnDelete();
$table->unique(['product_id', 'attribute_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('products_attributes');
Schema::rename('productos_variantes_values', 'productos_variantes_definiciones');
Schema::rename('attribute', 'productos_attributes');
}
};