I have checked the charger is fine
To do this, you left the charger and cable connected to another phone, correct?
tried to restart phone
Did you perform a Forced Restart? If not, follow the instructions very carefully, as this is a bit tricky. (Hint.....ignore the "slider" when it appears and keep holding the Side button in until the Apple logo appears. This might take another 30 seconds.)
Force restart iPhone - Apple Support
If the phone is still not charging reliably......there is an intermittent hardware problem with the phone. Make an appointment at the Apple Store or take the phone to an authorized Apple service shop. You can find a list of authorized shops in your area using this link:
Find Locations