rewrite query to use illuminate indices