Did Greek city-states allow foreigners and slaves as part of their armies?
No, the poleis did not have foreigners or slaves in their armies. This would have very much upset their politics and even the nature of their military.
Classical Greek armies relied on heavy infantry known as hoplites. The strength of a hoplite force was in its solidarity and its discipline. This was because hoplite warfare was predicated on massed formations of men supporting one another. Hoplites could not lose if they stayed in formation, but were easy to defeat if they broke. For this reason, it was better to have only free men of a certain status in the community fight because they could be relied on to stick together.
In addition, the hoplite's equipment cost a great deal. A hoplite needed to provide his own armor and weapons, which were not cheap. Therefore, only relatively wealthy men could afford to be hoplites.