$userObject->authored_knowledge->distinct()->where_related('group', 'id >', 0)->count(); ^^^^^^^^^^^^