public function has_related() {
        global $DB;
        $sql = "SELECT DISTINCT b.id
                    FROM {badge_related} br
                    JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                   WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3";
        return $DB->record_exists_sql($sql, ['badgeid' => $this->id, 'badgeid2' => $this->id, 'badgeid3' => $this->id]);
    }