Php 在雄辩的查询中获取数据透视列
我试图在同一个查询中检索一些模型和Php 在雄辩的查询中获取数据透视列,php,laravel,laravel-4,eloquent,Php,Laravel,Laravel 4,Eloquent,我试图在同一个查询中检索一些模型和pivot列 我有三张桌子 材料 id | name 布匹 id | name | item_id 项目\织物\材料 id | fabric_id | material_id | percentage 使用Item::with('fabrics','fabrics.materials')->查找(1) 我可以得到所有的布料和材料,但是百分比栏被省略了。如何使用它来实现这一点?在模型中添加了withPivot() return$this->belongsto
pivot
列
我有三张桌子
材料
id | name
布匹
id | name | item_id
项目\织物\材料
id | fabric_id | material_id | percentage
使用Item::with('fabrics','fabrics.materials')->查找(1)代码>
我可以得到所有的布料和材料,但是百分比栏被省略了。如何使用它来实现这一点?在模型中添加了withPivot()
return$this->belongstomy('Material'、'items\u fabrics\u materials')->withPivot('percentage')代码>