Besides the Jataka later cult Buddha did first say that.
It seems letting go of attachment was his earliest teaching.
In suttas there also Husbands that either want to be a monk or stay celibate laypersons and offers the wife(s) , the possibility to get another husband or looks for a husband for them.
I don’t know of a situation that I would have to be brave enough to lay down my life for other friends.
Would you?
This makes me remember what Jesus said