A good Samaritan ​who ​offered to lend two men short on cash a couple bucks to cover their meal at a Brooklyn eatery ended up beaten and robbed for trying to help, cops say.

The victim was savagely beaten by four men inside a Flatbush fried-chicken joint — and then robbed by a fifth as he lay helpless on the floor, cops say.

The 37-year-old victim told police that an argument began when he offered to help pay for the two men’s meal, which they were a few dollars short of paying for, inside Texas Chicken and Burgers in Flatbush on March 1.

The two men got angry at the offer and soon grabbed the victim’s cane and began striking him in the head and body with it and their fists, police said.

The men pummeled the victim harder when he tried to defend himself, and soon two other men entered the location to join in the beating.

When the attackers fled, another man entered the Texas Chicken and Burgers spot and emptied the victim’s pockets before fleeing, police said.

The victim was taken to an area hospital, where he was treated for multiple broken bones, contusions and lacerations.

Video from inside the restaurant shows the vicious attack as it unfolded in full view of other customers.