Attend them on laptop and put your phone in some other room.If u don't have a laptop,just log out of all possible apps and turn off notifications during a class.
Have breakfast and then sit down for your class in a comfortable spot. Keep your phone aside. Make notes during the class, try engaging more than usual.