Coherent control of photonic spin Hall effect in a Cavity