private function moveFieldData(CalendarEvent $event) {
        if ($event->Attendees()->exists()) {
            /** @var Attendee $attendee */
            foreach ($event->Attendees() as $attendee) {
                /** @var UserField $field */
                foreach ($event->Fields() as $field) {
                    $q = SQLSelect::create(
                        $field->FieldName,
                        "`{$attendee->getClassName()}`",
                        array('ID' => $attendee->ID)
                    );

                    try {
                        $value = $q->execute()->value();
                        $attendee->Fields()->add($field, array(
                            'Value' => $value
                        ));
                        echo "[$event->ID][$attendee->ID] Set '$field->FieldName' with '{$value}' \n";
                    } catch (\Exception $e) {
                        // fails silent
                        echo "[$event->ID][$attendee->ID] Failed, '$field->FieldName' does not exist \n";
                    }
                }
            }
            echo "[$event->ID] Finished migrating event \n\n";
        } else {
            echo "[$event->ID] No attendees to migrate \n\n";
        }
    }
private function moveFieldData(CalendarEvent $event) {
        if ($event->Attendees()->exists()) {
            /** @var Attendee $attendee */
            foreach ($event->Attendees() as $attendee) {
                /** @var UserField $field */
                foreach ($event->Fields() as $field) {
                    $q = SQLSelect::create(
                        $field->FieldName,
                        "`{$attendee->getClassName()}`",
                        array('ID' => $attendee->ID)
                    );

                    try {
                        $value = $q->execute()->value();
                        $attendee->Fields()->add($field, array(
                            'Value' => $value
                        ));
                        echo "[$event->ID][$attendee->ID] Set '$field->FieldName' with '{$value}' \n";
                    } catch (\Exception $e) {
                        // fails silent
                        echo "[$event->ID][$attendee->ID] Failed, '$field->FieldName' does not exist \n";
                    }
                }
            }
            echo "[$event->ID] Finished migrating event \n\n";
        } else {
            echo "[$event->ID] No attendees to migrate \n\n";
        }
    }
private function moveFieldData ( CalendarEvent $ event ) { if ( $ event -> Attendees ( ) -> exists ( ) ) { /** @var Attendee $attendee */ foreach ( $ event -> Attendees ( ) as $ attendee ) { /** @var UserField $field */ foreach ( $ event -> Fields ( ) as $ field ) { $ q = SQLSelect :: create ( $ field -> FieldName , "`{$attendee->getClassName()}`" , array ( 'ID' => $ attendee -> ID ) ) ; try { $ value = $ q -> execute ( ) -> value ( ) ; $ attendee -> Fields ( ) -> add ( $ field , array ( 'Value' => $ value ) ) ; echo "[$event->ID][$attendee->ID] Set '$field->FieldName' with '{$value}' \n" ; } catch ( \ Exception $ e ) { // fails silent echo "[$event->ID][$attendee->ID] Failed, '$field->FieldName' does not exist \n" ; } } } echo "[$event->ID] Finished migrating event \n\n" ; } else { echo "[$event->ID] No attendees to migrate \n\n" ; } }
Migrate the field data from the attendee model to relations
Use an SQLSelect to access the data directly from the database

@param CalendarEvent|TicketExtension $event
Migrate the field data from the attendee model to relations Use an SQLSelect to access the data directly from the database