增加关联关系
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user