SELECT k.attribute_title, GROUP_CONCAT(d.attribute_value)
FROM current_product_attributes AS k INNER JOIN
current_product_attribute_values as d
ON k.attribute_id = d.attribute_id AND k.attribute_uid = d.attribute_uid
WHERE d.product_id='28'
GROUP BY k.attribute_title
It works, but I need to convert it to laravel eloquent. I tried this code:
$final=DB::select(`k.attribute_title`, `GROUP_CONCAT(d.attribute_value)`)
->from(`current_product_attributes AS k`)
->join(`current_product_attribute_values as d `,function($join){
$join->on(`k.attribute_id = d.attribute_id AND k.attribute_uid = d.attribute_uid`);
})
->where(`d.product_id=$product_data->id`)
->groupBy(`k.attribute_title`)->get();
dd($final);
But I have this error:
Argument 1 passed to Illuminate\Database\Connection::prepareBindings() must be of the type array, null given
答案 0 :(得分:0)
您可以通过LARAVEL Orator进行此操作,它将原始查询转换为架构生成器查询,但是很遗憾,其在线工具的站点已关闭,因此请重试,然后提出问题