Apple has defeated a class action lawsuit brought against it by employees of the company's retail stores who were seeking back pay for time spent during mandatory daily security searches.

The decision, from US district Judge William Alsup in San Francisco, releases Apple from having to compensate more than 12,000 former and current employees at 52 stores throughout California for time spent over a six-year period waiting to have their bags and Apple devices searched when they went on breaks and at the end of their shifts. It's thought that if Apple had lost the case, the company could have ended up paying out as much as $60 million, plus penalties.

Plaintiffs Amanda Frlekin and Dean Pelle alleged that "screenings", or bag searches, designed to discourage theft, are conducted every time sales reps leave the store, including for meal breaks, according to Reuters.

Judge Alsup said in his ruling that workers were free to choose not to bring a bag to work, and thus would avoid the delays that came with a search. No Apple employee filed court papers asserting a special need to bring a bag, Alsup wrote. "Rather than prohibiting employees from bringing bags and personal Apple devices into the store altogether, Apple took a milder approach to theft prevention and offered its employees the option to bring bags and personal Apple devices into a store subject to the condition that such items must be searched when they leave the store."

The employees said that freedom to bring a bag to work was a "standard freedom." Apple argued last month that "put simply, if a class member voluntarily chooses to bring a duffle bag full of playing cards to work, purely for personal convenience, California law does not require Apple to pay that Class Member if Apple elects to search that duffle bag pursuant to its bag and technology check policies."

In July, Alsup granted class-action statues to the lawsuit, which was filed in 2013 by two former workers from Apple stores in New York and Los Angeles. The pair claimed that employees at Apple's physical locations were required to stand in line up to 30 minutes at a time while waiting for store managers to check their bags to ensure they weren't stealing items from the store. The employees said that these waiting times deprived them of many hours of unpaid wages, totaling about $1500 a year.

"Plaintiffs are disappointed in the court's ruling and are exploring their options, including an appeal," Lee Shalov, a lawyer for the workers, said in an email.

Last year, the US Supreme Court ruled that Amazon employees would not be compensated for the time they spent in security check lines. The court said that screenings were part of employees' jobs and benefitted the company.

Apple has not commented on the ruling.