Keeping erection hard in morning

Hi, I started having constipation 7/8 weeks ago and then one evening with a girl I was dating I couldn’t get it up. Then for a week I couldn’t get an erection. But after I went to toilet it has came back. But I haven’t got loads of confidence in it. And in the morning I can get one but it doesn’t last.

Can anyone help?