Created
October 30, 2017 10:40
-
-
Save YuraSk/aac388963e333ec017ea16fda215d0d5 to your computer and use it in GitHub Desktop.
group by with count laravel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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