Skip to content

Instantly share code, notes, and snippets.

@YuraSk
Created October 30, 2017 10:40
Show Gist options
  • Save YuraSk/aac388963e333ec017ea16fda215d0d5 to your computer and use it in GitHub Desktop.
Save YuraSk/aac388963e333ec017ea16fda215d0d5 to your computer and use it in GitHub Desktop.
group by with count laravel
return $this->count() // return 2258
return $this->groupBy('tid')->count() // return 9
return $this->groupBy('tid')->select('tid', DB::raw('COUNT(tid) as total'))->get(); // also bad result, return many raws of array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment