public function onAfterWrite()
    {
        parent::onAfterWrite();

        if (!$this->getOwner()->Contact()->exists()) {
            $sync = Config::inst()->get(Contact::class, 'sync_fields');
            $contact = Contact::create();

            foreach ($sync as $field) {
                $contact->$field = $this->getOwner()->$field;
            }

            $contact->MemberID = $this->getOwner()->ID;
            $contact->write();
        } else {
            $this->getOwner()->syncToContact();
        }


    }