Может кто-нибудь помочь, у меня нет идей.
У меня есть этот код:
$item = ItemsBrandOitb::select('ItmsGrpCod')->where('Brand', '=', $brand)->first();
return ItemsOitm::where('Country', $country)
->where('OnHand', '>', 0)
->where('ItmsGrpCod','=', $item->ItmsGrpCod)
->with([
'price' => function($q) use ($country){
return $q->where('Country', $country);
},
'stock'=> function($q) use ($country){
return $q->where('Country', $country);
},
'brand' => function($q) use ($brand){
return $q->whereHas('Brand', '=', $brand);
}
]
)->groupBy('U_GeralRef')->orderBy('ColectionDate', 'desc')->get();
Кто-нибудь знает, как поставить этот запрос:
$item = ItemsBrandOitb::select('ItmsGrpCod')->where('Brand', '=', $brand)->first();
//here:
->where('ItmsGrpCod','=', $item->ItmsGrpCod)
То есть у меня может быть только один запрос к базе данных?
Спасибо