fix : 주문 테이블 모델링 -> 추후 변경예정 (견적, 수주, 발주에 대한 각각의 컬럼을 위한 테이블 필요)
This commit is contained in:
38
app/Models/Orders/Order.php
Normal file
38
app/Models/Orders/Order.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Orders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Order extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
// 주문(견적/수주/발주 메인)
|
||||||
|
protected $table = 'orders';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'tenant_id', 'order_no', 'order_type_code', 'status_code', 'category_code', 'product_id',
|
||||||
|
'received_at', 'writer_id', 'client_id', 'client_contact', 'site_name', 'quantity', 'delivery_date',
|
||||||
|
'delivery_method_code', 'memo'
|
||||||
|
];
|
||||||
|
|
||||||
|
// 상세(라인)
|
||||||
|
public function items()
|
||||||
|
{
|
||||||
|
return $this->hasMany(OrderItem::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 이력
|
||||||
|
public function histories()
|
||||||
|
{
|
||||||
|
return $this->hasMany(OrderHistory::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 버전관리
|
||||||
|
public function versions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(OrderVersion::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Models/Orders/OrderHistory.php
Normal file
20
app/Models/Orders/OrderHistory.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Orders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class OrderHistory extends Model
|
||||||
|
{
|
||||||
|
// 이력/메모
|
||||||
|
protected $table = 'order_histories';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'tenant_id', 'order_id', 'history_type', 'content', 'created_by'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function order()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Order::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Models/Orders/OrderItem.php
Normal file
30
app/Models/Orders/OrderItem.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Orders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class OrderItem extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
// 주문 상세
|
||||||
|
protected $table = 'order_items';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'tenant_id', 'order_id', 'serial_no', 'product_id', 'quantity',
|
||||||
|
'status_code', 'design_code', 'remarks', 'attributes'
|
||||||
|
];
|
||||||
|
|
||||||
|
// 투입 구성(자재/BOM 등)
|
||||||
|
public function components()
|
||||||
|
{
|
||||||
|
return $this->hasMany(OrderItemComponent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function order()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Order::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Models/Orders/OrderItemComponent.php
Normal file
24
app/Models/Orders/OrderItemComponent.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Orders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class OrderItemComponent extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
// 투입구성(자재, 제품, 부품, BOM)
|
||||||
|
protected $table = 'order_item_components';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'tenant_id', 'order_item_id', 'component_type', 'component_id', 'quantity',
|
||||||
|
'unit', 'price', 'remarks', 'created_by', 'updated_by'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function orderItem()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(OrderItem::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Models/Orders/OrderVersion.php
Normal file
20
app/Models/Orders/OrderVersion.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Orders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class OrderVersion extends Model
|
||||||
|
{
|
||||||
|
// 주문 버전관리(변경사항만 저장)
|
||||||
|
protected $table = 'order_versions';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'tenant_id', 'order_id', 'version_no', 'version_type', 'status_code', 'changed_fields', 'created_by', 'change_note'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function order()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Order::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user