0
我使用Laravel 5.3。这是我的查询,我想在结果数组中将'children_rec'重命名为'node'。如何在口头上重新命名关系函数?
$boxes = Boxes::with('children_rec')
->whereNull('box_id')
->with('position')
->get()
->toJson(128);
UPDATE: 关系码:
public function child()
{
return $this
->hasMany('PTA_OIMS\Boxes', 'box_id');
}
public function children_rec()
{
return $this->child()
->with('children_rec')
->with('position');
}
感谢
是什么,返回结构是什么样子?为什么你不能操纵数组? – tadman
@tadman:结果结构:https://pastebin.com/NFfWS0s2 –
编辑您的问题以包含任何相关代码,请不要将它作为混乱评论添加。 – tadman