Being laid off sucks and it hurts, but it happens to everyone. I think it's important to remember that being laid off doesn't mean there's anything wrong with you. It's simply something happening.
If you're interested in learning more about handling hardships mentally, take a look at Meditations by Marcus Aurelius.