I would like to optimize this code. If you see some stupid things, or you have better way to rewrite this code, please let me know.
$event = $eventsTable->getEvent($eventId, ['all']);
foreach ($event['tickets'] as $ticketId => $ticket) {
$ticket['ticket_id'] = null;
$ticket['ticket_event_id'] = null;
array_replace($event['tickets'][$ticketId], array_push($event['tickets'], $ticket));
unset($event['tickets'][$ticketId]);
}
$form->populate($event);
This code works, but I have doubt about technical stuff.
EDIT: My problem was to get ticket from existed events, duplicate data and unset ticket_id and ticket_event_id and save as a new ticket