findTargetOrders(array $itemIds): iterable { $sql = <<<EOT SELECT * FROM orders WHERE (SELECT COUNT(*) FROM order_details WHERE orders.id=order_details.order_id AND order_details.item_id=? AND COUNT(*)>?) EOT; return $this->newQuery()->selectRaw($sql, $itemIds)->get(); } 12