Answer :

An idiom is a phrase that will not directly translate into another language. For example it's raining cats and dogs or to say someone is being a pain in the neck where as a metaphor simply states something is something which it is not for example, the stars were diamonds piercing though a velvet night.
Idiom is a word or phrase that means something different then its own meaning.

Ex: a piece of cake.

This doesn't mean a piece of a cake( literal meaning), it means an easy task.

Metaphor is a way of describing somethibg by comparing it too something else.

Ex: He is a couch potato

Here we are comparing a person who is very lazy to a potato. We are telling that he is always on the couch.

Idioms and metaphors are very same and yet very different at the same time. The only way to understand them is to see where we are comparing and where we are just giving an example.

Hope it helped!