Laravel - Querybuilder with join and concat
Logan's answer got my started in the right direction. I also had to remove all of the 'user.' prefixes since it was calling the Users model already I suppose. This query worked:
User::select(DB::raw('CONCAT(last_name, ", ", first_name) AS full_name'), 'id')
->join('users_groups', 'id', '=', 'users_groups.user_id')
->where('activated', '=', '1')
->where('users_groups.group_id', '=', $group)
->orderBy('last_name')
->lists('full_name', 'id');
Thanks everyone! Hopefully if someone else runs into this they will find guidance with this question.
You do not need to select in DB::raw(), See the example
User::select(
'id',
DB::raw('CONCAT(first_name," ",last_name) as full_name')
)
->orderBy('full_name')
->lists('full_name', 'id');