0
$item_ids = array('1', '17');
중 하나를 가지고있는 모든 Shop
을 얻으려고합니다.어디에서 예상대로 작동하지 않습니다
그러나 아래 코드는 내가 기대했던대로 그렇게하지 않습니다. 단지 모든 상점을 나에게 건네줍니다.
$shops = Shop::whereHas('items', function($query) use ($item_ids) {
$query->where('items.id', '=', $item_ids[0]);
foreach(array_slice($item_ids, 1) as $item_id) {
$query->orWhere('items.id', '=', $item_id);
}
})
->get(array('shops.id', 'shops.shop_name', 'shops.lat', 'shops.lng'));
내가는 지정된 Item
들 중 하나를 사용하여 Shop
의를받을 수 있나요?