增加关联关系

This commit is contained in:
mzl
2025-09-04 11:52:40 +08:00
parent 87679588b4
commit ced046aa18
11 changed files with 140 additions and 660 deletions
+25
View File
@@ -59,4 +59,29 @@ class VehMoneyValue extends Model
if ($this->exchange_rate === null) return null;
return (string) bcmul((string)$this->amount, (string)$this->exchange_rate, $scale);
}
/**
* 关联订单
*/
public function order()
{
return $this->belongsTo(StockOrders::class, 'object_id', 'id');
}
/**
* 关联订单项(一个货币价值记录可能关联到订单项)
*/
public function orderItem()
{
return $this->belongsTo(StockOrderItems::class, 'object_id', 'id');
}
/**
* 限定查询特定对象类型的货币价值记录
*/
public function scopeOfScene($query, $scene)
{
return $query->where('object_scene', $scene);
}
}