On the physics of radio haloes in galaxy clusters: scaling relations and luminosity functions