What you need are
these type of legs, which unfortunately are getting increasingly harder to find.
From our pop-up days we've always liked keeping the table outside. The last couple of years they've moved away from folding table legs in hybrids and pop-ups and use a screwy cantelver thing. Very clunky. So we replaced them with the above type of leg. Quick to fold up, easy to move around or outside. And the table simply drops into the slots to make it a bed. So you may have to make your own stopper on the wall to use it as a bed since you're removing the swing hinge.