Brug ||
operatør for at udføre strengsammenkædning, og aggregér derefter dette resultat.
$repairs = DB::select(DB::raw("
select r.id repair_id, string_agg(w.name || ' ' || w.surname, ', ') workers
from repairs r
join repair_worker rw on r.id = rw.repair_id
join workers w on w.id = rw.worker_id
where r.vehicle_id = ?
group by r.id
"),[$vehicle->id]);