moneyLatest('unit_price')?->amount; } public function getHandlingFeeAmountAttribute() { return $this->moneyLatest('handling_fee')?->amount; } public function getFobTransportFeeAmountAttribute() { return $this->moneyLatest('fob_transport_fee')?->amount; } public function getPortMiscFeeAmountAttribute() { return $this->moneyLatest('port_misc_fee')?->amount; } public function getRetrofitFeeAmountAttribute() { return $this->moneyLatest('retrofit_fee')?->amount; } public function getTotalPriceAmountAttribute() { return $this->moneyLatest('total_price')?->amount; } /** * 关联主订单 */ public function order() { return $this->belongsTo(StockOrders::class, 'order_id', 'id'); } /** * 关联订单项选项 */ public function options() { return $this->hasMany(StockOrderItemOptions::class, 'order_item_id', 'id'); } /** * 关联货币价值信息(一个订单项可以有多个货币价值记录) */ public function moneyValues() { return $this->hasMany(VehMoneyValue::class, 'object_id', 'id') ->where('object_scene', 'stock_order_items'); // 场景标识区分不同对象类型 } }