feat: products 및 materials 테이블에 is_active 컬럼 추가

- is_active 컬럼 추가 마이그레이션 (default 1)
- Product 모델 fillable 및 casts 업데이트
- Material 모델 fillable 및 casts 업데이트
- Material 모델에 material_type fillable 추가
- ModelTrait의 scopeActive() 메서드 지원
This commit is contained in:
2025-11-17 14:55:31 +09:00
parent 7b8f8791c9
commit 517d5940e9
3 changed files with 51 additions and 1 deletions

View File

@@ -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 = [

View File

@@ -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 = [

View File

@@ -0,0 +1,46 @@
<?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
{
// products 테이블에 is_active 추가
Schema::table('products', function (Blueprint $table) {
$table->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');
});
}
};