Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tisuchi/7eaa9aff7b0c68db1f25d832e87f014c to your computer and use it in GitHub Desktop.
Save tisuchi/7eaa9aff7b0c68db1f25d832e87f014c to your computer and use it in GitHub Desktop.
Laravel fetch results grouped by days | Larademy.com
$users = User::where('created_at', '>=', \Carbon\Carbon::now->subMonth())
->groupBy('date')
->orderBy('date', 'DESC')
->get(array(
DB::raw('Date(created_at) as date'),
DB::raw('COUNT(*) as "views"')
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment