Chosen Solution

I was given a MacBook Pro Mid 2012 from a friend but it wont detect any internal hard drive but will boot fine from USB and will recognize a cd put in the DVD drive and I can hear the hard drive spin up when the Mac is booted. I have tried 2 WD Blue HDDs and a 860 QVO Samsung SSD so I don’t think it is the fault of the hard drive and I have also tried a Mountain Lion installer and the Catalina installer.

More than likely this is an issue with the hard drive cable itself. This particular model is known for that cable becoming faulty. It’s a pretty inexpensive fix, and honestly, I usually recommend people replace this cable when they do hard drive upgrades/replacements anyways, just to avoid it being an unforeseen issue. MacBook Pro 13" Unibody Mid 2012 Hard Drive Cable Replacement