我的用户模型
var responseJSON RespJson
responseJSON = RespJson{
Value1: "dataExample",
Value2: "dataExample",
}
c.Data["json"] = &responseJSON
c.ServeJSON()
我的控制器:
public function children()
{
return $this->hasMany('App\User', 'lrn_partner', 'lrn')->with('children');
}
最后,我有一个具有所有递归关系的大对象。但是,为了将所有关系都放在一个列表中,我在刀片视图中做到了:
$network = User::with('children')->lrn('123')->first();
我的问题是,如何在没有刀片但有数组的情况下将所有关系放在一个列表(集合)中?为什么我需要数组?因为我需要提供API。
谢谢!