Eloquent
$staffGroup = StaffGroup::where('id', $id)
->with('staffGroupRight')
->first();
In StaffGroup
Model
:
public function staffGroupRight() {
return $this->hasMany('Modules\Staff\Http\Models\StaffGroupRight');
}
我所拥有的是,
public function staffGroupRight() {
return $this->hasMany('Modules\Staff\Http\Models\StaffGroupRight')->take(5);
}
但它总共给出了 5 行staff_group
但我想要它limit
对于一个staff_group
例如
有 10 个staff_group
然后它给出了 5 条记录staffgrouprights
对于那10staff_group
但我想要 5 个单人staff_group
在这里与staffGroupRight
return data
适当id
of staff group
.
但我想设置limit
在那里面with()
方法数据。
是否可以设置limit
in with()
方法与否...?
$staffGroup = StaffGroup::where('id', $id)
->with(['staffGroupRight' => function($query){
return $query->take(10);
}])
->first();
我假设您想要获取 StaffGroupRight 的 10 条记录。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)