Sheriff’s Deputy Moises Carotti was known to keep an eye out for people sleeping where they weren’t supposed to — and then someone reported him dozing in his own patrol car.

Carotti, an 18-year veteran of the force, was suspended with pay last week after a student said he was sleeping while guarding Marjory Stoneman Douglas High School, weeks after a gunman killed 17 people there.

The allegation was a switch for a deputy who was commended in 2016, according to his personnel file.

Sgt. Nicholas DeGiovani lauded Carotti in his annual evaluation, noting that Carotti took the initiative to patrol the beach in Deerfield, “checking lifeguard towers to make sure nobody was sleeping or trespassing inside of them.”

Carotti, 39, served in the Air Force before joining the Sheriff’s Office in 1999. He began with the agency as a corrections officer, then was assigned to be a road deputy in Oakland Park in 2012 and then to Deerfield Beach in 2015, his personnel records show.

He was recognized as the Deputy of the Month in July last year for two efforts: He apprehended an aggravated assault suspect and also retrieved a purse snatched from the Starbucks on Federal Highway in Deerfield Beach.

He also was nominated for Deputy of the Month other times. He was commended for his role in stopping a man accused of groping underage girls as they carried a paddleboard into the ocean. He also helped rescue people who had jumped off the Deerfield Beach International Fishing Pier in an attempt to elude deputies but then found themselves caught in a dangerous tide.

In the same 2016 memo where he was praised for working to stop beach trespassers, he also was urged to improve his work performance.

He had missed mandatory court appearances “a few times,” and he also was once late to report that he had a scheduling conflict for a court hearing, the documents state.

Earlier in his career, a 2003 notice said he had an unacceptable number of tardy appearances and absences.

The Sheriff’s Office has begun an internal affairs investigation into last week’s alleged incident involving Carotti.

A student who notified a sergeant patrolling the school that Carotti was asleep in his patrol car, the Sheriff’s Office said. The sergeant knocked on Carotti’s window to wake him up, the agency said.

Carotti was working as a road patrol deputy in the Deerfield Beach district before his assignment at Stoneman Douglas. The Sheriff’s Office hasn’t released additional details about Carotti’s assignment at the school.

Jeff Bell, president of the union representing Broward County deputies, said Carotti is one of its members and that the union intends to help Carotti fight the allegation.

“The union would sincerely like to apologize if we gave the impression that one of the deputies might have been sleeping in a vehicle,” he said.

He added that state law prohibits any further discussion of an open investigation.

Carotti couldn’t be reached for comment.

Broward County Sheriff Scott Israel told the South Florida Sun Sentinel last week that he was disheartened to learn of the allegations that led to Carotti’s suspension.

“That a deputy was sleeping is incredibly disappointing,” Israel said. “As you know, I can’t comment on an ongoing internal affairs investigation, but once the findings are in I will make the appropriate decisions regarding the way we are going to handle it and the level of discipline.”