A very secure solution uses an optocouple. As 1kΩ resistor is good for an input voltage range of 5 to 20 volts.
The output is inverted, that means, the Pi senses low on it's GPIO if there is 5–12V on the input, and high if not.

simulate this circuit – Schematic created using CircuitLab