How to use group_concat with groupBy function?

Solution:

If you’re trying to access the group_contact property, you need to name it. Otherwise, MySQL will name the column with the function name.

DB::raw('group_concat(users.id) AS id')