Skip to content

Instantly share code, notes, and snippets.

@alysdal
Created December 7, 2016 17:52
Show Gist options
  • Save alysdal/eaf4e8115d7375d5411c45872c38dcb9 to your computer and use it in GitHub Desktop.
Save alysdal/eaf4e8115d7375d5411c45872c38dcb9 to your computer and use it in GitHub Desktop.
$groups = Groups::all();
$arr = [];
foreach ($groups as $group) {
$item = $group->toArray();
$item['active_bets'] = $group->bets()->active()->count(); // går ud fra du har lavet et eloquent scope der hedder active
$arr[] = $item;
}
return response()->json($arr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment