$data = DB::table("productTesting")
->select("productTesting.*","categories.*")
->join(DB::raw("(SELECT
categories.id,
GROUP_CONCAT(categories.name) as categoriesName
FROM categories
GROUP BY categories.id
) as categories"),function($join){
$join->on("categories.id","=","productTesting.categoryId");
})
->groupBy("productTesting.id")
->get();
dd($data);
Laravel