我有一个名为 user 的模型 与关系“旅行”模型 以及具有“目的地”关系的旅行模型
如何让用户能够 Eloquent 地谈论旅行和关系。
我知道我可以这样旅行:
$row = $this->model
->find($reqId)
->with('travel')
->first();
我想要获取旅行目的地。
最佳答案
如果我正确理解你的问题,你想使用 nested eager loading :
$row = $this->model->with('travel', 'travel.destination')->find($reqId)
关于拉拉维尔 5.1 : get relation in with,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41518823/