Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. $groups = Groups::all();
  2. $arr = [];
  3.  
  4. foreach ($groups as $group) {
  5. $item = $group->toArray();
  6. $item['active_bets'] = $group->bets()->active()->count(); // går ud fra du har lavet et eloquent scope der hedder active
  7. $arr[] = $item;
  8. }
  9.  
  10. return response()->json($arr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement