Improve has for nested relations

The same as https://github.com/laravel/framework/pull/4237 only greatly simplified ;)