A quantum approach to cavity mediated laser cooling