Как get_models_by_brand
(сгруппировано по body_type
)?
У меня есть эти таблицы ----> 1.models
, 2.brands
, 3.body_type
Я хочу сделать запрос, по которому модели по марке будут сгруппированы по body_type
, как показано ниже
{
{
"sedan" : ["316","318"]
},
{
"coupe" : ["z3","z4"]
},
}
Вот так я получаю бренды ---- контрольный файл
public function getBrands()
{
$brands = DB::table('brands')
->join('countries', 'brands.country_id', 'countries.country_id')
->where('brands_status', 1)
->select('brands.brands_id','brands.brands_name','brands.brands_name_ar',
'brands.brands_logo_url','countries.country_name','countries.country_name_ar')
->get()->toArray();
return response()->json(new Response(true, $brands));
}