【发布时间】:2018-03-20 17:59:04
【问题描述】:
我使用 Laravel 5.3。这是我的查询,我希望在结果数组中将“children_rec”重命名为“node”。
$boxes = Boxes::with('children_rec')
->whereNull('box_id')
->with('position')
->get()
->toJson(128);
更新: 关系代码:
public function child()
{
return $this
->hasMany('PTA_OIMS\Boxes', 'box_id');
}
public function children_rec()
{
return $this->child()
->with('children_rec')
->with('position');
}
谢谢
【问题讨论】:
-
返回结构是什么样的?为什么不能直接操作数组?
-
@tadman:结果结构:pastebin.com/NFfWS0s2
-
编辑您的问题以包含任何相关代码,请不要将其添加为杂乱的评论。
-
你可能需要使用
witheloquent