$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);
}
but it gives total 5 rows for all staff_group but i want it to limit for one staff_group
There are 10 staff_group then it gives 5 records of staffgrouprights for that 10 staff_group but i want it 5 for single staff_group
here with staffGroupRight return data appropriate to id of staff group.
but i want to set limit in that with() method data.
is it possible to set limit in with() method or not...??
$staffGroup = StaffGroup::where('id', $id)
->with(['staffGroupRight' => function($query){
return $query->take(10);
}])
->first();
I assume you want to take 10 record of staffGroupRight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With