From 517d5940e9cb81c64f8a3835d2d2c96f71417e33 Mon Sep 17 00:00:00 2001 From: hskwon Date: Mon, 17 Nov 2025 14:55:31 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20products=20=EB=B0=8F=20materials=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90=20is=5Factive=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - is_active 컬럼 추가 마이그레이션 (default 1) - Product 모델 fillable 및 casts 업데이트 - Material 모델 fillable 및 casts 업데이트 - Material 모델에 material_type fillable 추가 - ModelTrait의 scopeActive() 메서드 지원 --- app/Models/Materials/Material.php | 3 ++ app/Models/Products/Product.php | 3 +- ...ctive_to_products_and_materials_tables.php | 46 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2025_11_17_145307_add_is_active_to_products_and_materials_tables.php diff --git a/app/Models/Materials/Material.php b/app/Models/Materials/Material.php index 26f8533..0c58398 100644 --- a/app/Models/Materials/Material.php +++ b/app/Models/Materials/Material.php @@ -24,6 +24,7 @@ class Material extends Model 'item_name', 'specification', 'material_code', + 'material_type', 'unit', 'is_inspection', 'search_tag', @@ -32,11 +33,13 @@ class Material extends Model 'options', 'created_by', 'updated_by', + 'is_active', ]; protected $casts = [ 'attributes' => 'array', 'options' => 'array', + 'is_active' => 'boolean', ]; protected $hidden = [ diff --git a/app/Models/Products/Product.php b/app/Models/Products/Product.php index 33076a9..53825eb 100644 --- a/app/Models/Products/Product.php +++ b/app/Models/Products/Product.php @@ -28,7 +28,7 @@ class Product extends Model 'specification_file', 'specification_file_name', 'certification_file', 'certification_file_name', 'certification_number', 'certification_start_date', 'certification_end_date', - 'created_by', 'updated_by', + 'created_by', 'updated_by', 'is_active', ]; protected $casts = [ @@ -41,6 +41,7 @@ class Product extends Model 'is_purchasable' => 'boolean', 'is_producible' => 'boolean', 'is_variable_size' => 'boolean', + 'is_active' => 'boolean', ]; protected $hidden = [ diff --git a/database/migrations/2025_11_17_145307_add_is_active_to_products_and_materials_tables.php b/database/migrations/2025_11_17_145307_add_is_active_to_products_and_materials_tables.php new file mode 100644 index 0000000..25a4815 --- /dev/null +++ b/database/migrations/2025_11_17_145307_add_is_active_to_products_and_materials_tables.php @@ -0,0 +1,46 @@ +tinyInteger('is_active') + ->default(1) + ->after('updated_by') + ->comment('활성 상태 (1: 활성, 0: 비활성)'); + }); + + // materials 테이블에 is_active 추가 + Schema::table('materials', function (Blueprint $table) { + $table->tinyInteger('is_active') + ->default(1) + ->after('updated_by') + ->comment('활성 상태 (1: 활성, 0: 비활성)'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // products 테이블에서 is_active 제거 + Schema::table('products', function (Blueprint $table) { + $table->dropColumn('is_active'); + }); + + // materials 테이블에서 is_active 제거 + Schema::table('materials', function (Blueprint $table) { + $table->dropColumn('is_active'); + }); + } +};