diff --git a/app/Domains/Catalog/Models/CatalogItem.php b/app/Domains/Catalog/Models/CatalogItem.php index d8c0627..22652d9 100644 --- a/app/Domains/Catalog/Models/CatalogItem.php +++ b/app/Domains/Catalog/Models/CatalogItem.php @@ -140,7 +140,7 @@ class CatalogItem extends Model 'catalog_item_id', 'attachment_id' ) - ->withPivot('orden') + ->withPivot(['orden', 'is_enabled']) ->wherePivotNull('variant_id') ->orderByPivot('orden'); } diff --git a/app/Domains/Catalog/Models/Variant.php b/app/Domains/Catalog/Models/Variant.php index 49990da..39b685e 100644 --- a/app/Domains/Catalog/Models/Variant.php +++ b/app/Domains/Catalog/Models/Variant.php @@ -91,7 +91,7 @@ class Variant extends Model 'variant_id', 'attachment_id' ) - ->withPivot('orden') + ->withPivot(['orden', 'is_enabled']) ->orderByPivot('orden'); if ($this->catalog_item_id !== null) { diff --git a/database/migrations/2026_08_14_020000_add_is_enabled_to_catalog_item_attachments.php b/database/migrations/2026_08_14_020000_add_is_enabled_to_catalog_item_attachments.php new file mode 100644 index 0000000..95ccd84 --- /dev/null +++ b/database/migrations/2026_08_14_020000_add_is_enabled_to_catalog_item_attachments.php @@ -0,0 +1,22 @@ +boolean('is_enabled')->default(true)->after('orden'); + }); + } + + public function down(): void + { + Schema::table('catalog_items_attachments', function (Blueprint $table): void { + $table->dropColumn('is_enabled'); + }); + } +}; diff --git a/tests/Feature/Catalog/CatalogItemControllerTest.php b/tests/Feature/Catalog/CatalogItemControllerTest.php index 1b86f43..4e2e359 100644 --- a/tests/Feature/Catalog/CatalogItemControllerTest.php +++ b/tests/Feature/Catalog/CatalogItemControllerTest.php @@ -62,6 +62,7 @@ class CatalogItemControllerTest extends TestCase 'catalog_item_id' => $item->id, 'variant_id' => $variant->id, 'orden' => 0, + 'is_enabled' => true, ]); } diff --git a/tests/Feature/Catalog/CatalogSchemaTest.php b/tests/Feature/Catalog/CatalogSchemaTest.php index 6f5122d..ad89e39 100644 --- a/tests/Feature/Catalog/CatalogSchemaTest.php +++ b/tests/Feature/Catalog/CatalogSchemaTest.php @@ -104,6 +104,7 @@ class CatalogSchemaTest extends TestCase 'catalog_item_id', 'attachment_id', 'orden', + 'is_enabled', ], Schema::getColumnListing('catalog_items_attachments')); } @@ -170,12 +171,14 @@ class CatalogSchemaTest extends TestCase 'variant_id' => null, 'attachment_id' => $itemAttachment->id, 'orden' => 2, + 'is_enabled' => true, ]); $this->assertDatabaseHas('catalog_items_attachments', [ 'catalog_item_id' => $item->id, 'variant_id' => $variant->id, 'attachment_id' => $variantAttachment->id, 'orden' => 3, + 'is_enabled' => true, ]); }