dnpage's solution to function count() needing to check whether query is fluent or eloquent