From b4b888adef4c00f808f5bc2d4ba131aca988a0e3 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Tue, 14 Jul 2026 13:30:07 -0300 Subject: [PATCH] feat: add FeaturedGroup and FeaturedProduct models with migrations for database structure --- app/Domains/Product/Models/FeaturedGroup.php | 20 +++++++++++++ .../Product/Models/FeaturedProduct.php | 25 ++++++++++++++++ ...14_161848_create_featured_groups_table.php | 30 +++++++++++++++++++ ..._161849_create_featured_products_table.php | 30 +++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 app/Domains/Product/Models/FeaturedGroup.php create mode 100644 app/Domains/Product/Models/FeaturedProduct.php create mode 100644 database/migrations/2026_07_14_161848_create_featured_groups_table.php create mode 100644 database/migrations/2026_07_14_161849_create_featured_products_table.php diff --git a/app/Domains/Product/Models/FeaturedGroup.php b/app/Domains/Product/Models/FeaturedGroup.php new file mode 100644 index 0000000..3015e08 --- /dev/null +++ b/app/Domains/Product/Models/FeaturedGroup.php @@ -0,0 +1,20 @@ +hasMany(FeaturedProduct::class); + } +} diff --git a/app/Domains/Product/Models/FeaturedProduct.php b/app/Domains/Product/Models/FeaturedProduct.php new file mode 100644 index 0000000..2e54f22 --- /dev/null +++ b/app/Domains/Product/Models/FeaturedProduct.php @@ -0,0 +1,25 @@ +belongsTo(FeaturedGroup::class); + } + + public function product(): BelongsTo + { + return $this->belongsTo(Product::class); + } +} diff --git a/database/migrations/2026_07_14_161848_create_featured_groups_table.php b/database/migrations/2026_07_14_161848_create_featured_groups_table.php new file mode 100644 index 0000000..15ac9a7 --- /dev/null +++ b/database/migrations/2026_07_14_161848_create_featured_groups_table.php @@ -0,0 +1,30 @@ +id(); + $table->string('tenant_codigo'); + $table->string('group_name'); + $table->enum('product_layout', ['row', 'column_with_image', 'column_with_cart']); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('featured_groups'); + } +}; diff --git a/database/migrations/2026_07_14_161849_create_featured_products_table.php b/database/migrations/2026_07_14_161849_create_featured_products_table.php new file mode 100644 index 0000000..cae9a84 --- /dev/null +++ b/database/migrations/2026_07_14_161849_create_featured_products_table.php @@ -0,0 +1,30 @@ +id(); + $table->foreignId('featured_group_id')->constrained('featured_groups')->onDelete('cascade'); + $table->unsignedBigInteger('product_id'); + $table->integer('order')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('featured_products'); + } +};