murat1709 Sorgu ile yapabilirsiniz:
DB::table('users')
->selectRaw('course_id, count(*) as total')
->groupBy('course_id')
->orderByDesc('total')
->get();
+-----------+-------+
| course_id | total |
+-----------+-------+
| 23 | 112 |
| 8 | 96 |
| 2 | 55 |
| 9 | 12 |
| 11 | 1 |
+-----------+-------+