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