Have you check the Magsafe port on the laptop to make sure the pins are Ok and there is no small metal object however small stuck to the port preventing the charger from seating properly? Have you tried to wiggle the magsafe to make sure it is seated? Many times I have to do this in order to get the laptop to register the charger is connected. See this Apple article as well:
https://support.apple.com/en-us/HT203207
If there is nothing stuck to the port and none of the other troubleshooting steps help, then you will need to have the laptop repaired.