fix an issue where querying relations with multiple whereHas statements and test it

When using multiple whereHas() statements like: User::whereHas('roles'..)->whereHas('permissions',...) would consider all the queries after the first whereHas() to be run on the parent model instead of the related model.