feat: Phase 5 - 참조 테이블 모델 item_id 마이그레이션

- Order 모델: product_id 제거, item_id 추가, item() 관계 추가
- OrderItem 모델: product_id 제거, item_id 추가, item() 관계 추가
- Quote 모델: product_id 제거, item_id 추가, item() 관계 추가
- MaterialReceipt 모델: material_id 제거, item_id 추가, material() → item() 변경
- Lot 모델: Material import 제거, material() → item() 변경

DB 스키마는 이미 마이그레이션됨 (2025_12_13_153544)
기존 product_id/material_id 컬럼은 DB에 남아있지만 fillable에서 제거

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-14 01:20:18 +09:00
parent 20ad6da164
commit 4f3b218441
5 changed files with 35 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models\Materials;
use App\Models\Items\Item;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -13,15 +14,15 @@ class MaterialReceipt extends Model
use SoftDeletes;
protected $fillable = [
'material_id', 'receipt_date', 'lot_number', 'received_qty', 'unit',
'item_id', 'receipt_date', 'lot_number', 'received_qty', 'unit',
'supplier_name', 'manufacturer_name', 'purchase_price_excl_vat',
'weight_kg', 'status_code', 'is_inspection', 'inspection_date', 'remarks',
];
// 자재 마스터
public function material()
// 품목 (통합 items 테이블)
public function item()
{
return $this->belongsTo(Material::class, 'material_id');
return $this->belongsTo(Item::class, 'item_id');
}
// 수입검사 내역

View File

@@ -2,6 +2,7 @@
namespace App\Models\Orders;
use App\Models\Items\Item;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -16,7 +17,7 @@ class Order extends Model
protected $table = 'orders';
protected $fillable = [
'tenant_id', 'order_no', 'order_type_code', 'status_code', 'category_code', 'product_id',
'tenant_id', 'order_no', 'order_type_code', 'status_code', 'category_code', 'item_id',
'received_at', 'writer_id', 'client_id', 'client_contact', 'site_name', 'quantity', 'delivery_date',
'delivery_method_code', 'memo',
];
@@ -38,4 +39,10 @@ public function versions()
{
return $this->hasMany(OrderVersion::class);
}
// 품목 (통합 items 테이블)
public function item()
{
return $this->belongsTo(Item::class, 'item_id');
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Models\Orders;
use App\Models\Items\Item;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -16,7 +17,7 @@ class OrderItem extends Model
protected $table = 'order_items';
protected $fillable = [
'tenant_id', 'order_id', 'serial_no', 'product_id', 'quantity',
'tenant_id', 'order_id', 'serial_no', 'item_id', 'quantity',
'status_code', 'design_code', 'remarks', 'attributes',
];
@@ -30,4 +31,10 @@ public function order()
{
return $this->belongsTo(Order::class);
}
// 품목 (통합 items 테이블)
public function item()
{
return $this->belongsTo(Item::class, 'item_id');
}
}

View File

@@ -2,7 +2,7 @@
namespace App\Models\Qualitys;
use App\Models\Materials\Material;
use App\Models\Items\Item;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -13,10 +13,10 @@ class Lot extends Model
{
use SoftDeletes;
// 자재 마스터
public function material()
// 품목 (통합 items 테이블)
public function item()
{
return $this->belongsTo(Material::class, 'material_id');
return $this->belongsTo(Item::class, 'item_id');
}
// 판매 기록

View File

@@ -2,6 +2,7 @@
namespace App\Models\Quote;
use App\Models\Items\Item;
use App\Models\Members\User;
use App\Models\Orders\Client;
use App\Traits\BelongsToTenant;
@@ -32,7 +33,7 @@ class Quote extends Model
'site_code',
// 제품 정보
'product_category',
'product_id',
'item_id',
'product_code',
'product_name',
// 규격 정보
@@ -133,6 +134,14 @@ public function client(): BelongsTo
return $this->belongsTo(Client::class);
}
/**
* 품목 (통합 items 테이블)
*/
public function item(): BelongsTo
{
return $this->belongsTo(Item::class, 'item_id');
}
/**
* 확정자
*/