我有一个这样返回的集合:
$scheduleLoads = Load::with('shipment','driver','tractor');
现在,我的问题与with问题有关-有没有办法将这些关系的关系添加到我返回的收藏夹中?
例如:
在Load
模型中,我与shipment
具有以下关系:
public function shipment(){
return $this->belongsTo(shipment::class, 'shipmentID');
}
在shipment
模型中,我具有以下关系:
public function shiptoAccount(){
return $this->belongsTo('App\Customer', 'ship_to');
}
是否有一种方法可以包含与Loads集合关联的shipment
的shiptoAccount返回?
答案 0 :(得分:1)
使用“点”语法(documentation):
$scheduleLoads = Load::with('shipment.shiptoAccount', 'driver', 'tractor');