55use HiEvents \DomainObjects \CapacityAssignmentDomainObject ;
66use HiEvents \DomainObjects \CheckInListDomainObject ;
77use HiEvents \DomainObjects \Enums \EventImageType ;
8+ use HiEvents \DomainObjects \Enums \QuestionBelongsTo ;
89use HiEvents \DomainObjects \EventDomainObject ;
910use HiEvents \DomainObjects \EventSettingDomainObject ;
1011use HiEvents \DomainObjects \ImageDomainObject ;
@@ -79,6 +80,10 @@ public function duplicateEvent(
7980 cloneEventSettings: $ duplicateSettings ,
8081 );
8182
83+ if ($ duplicateQuestions ) {
84+ $ this ->clonePerOrderQuestions ($ event , $ newEvent ->getId ());
85+ }
86+
8287 if ($ duplicateTickets ) {
8388 $ this ->cloneExistingTickets (
8489 event: $ event ,
@@ -153,7 +158,7 @@ private function cloneExistingTickets(
153158 }
154159
155160 if ($ duplicateQuestions ) {
156- $ this ->cloneQuestions ($ event , $ newEventId , $ oldTicketToNewTicketMap );
161+ $ this ->clonePerTicketQuestions ($ event , $ newEventId , $ oldTicketToNewTicketMap );
157162 }
158163
159164 if ($ duplicatePromoCodes ) {
@@ -174,23 +179,47 @@ private function cloneExistingTickets(
174179 /**
175180 * @throws Throwable
176181 */
177- private function cloneQuestions (EventDomainObject $ event , int $ newEventId , array $ oldTicketToNewTicketMap ): void
182+ private function clonePerTicketQuestions (EventDomainObject $ event , int $ newEventId , array $ oldTicketToNewTicketMap ): void
178183 {
179184 foreach ($ event ->getQuestions () as $ question ) {
180- $ this ->createQuestionService ->createQuestion (
181- (new QuestionDomainObject ())
182- ->setTitle ($ question ->getTitle ())
183- ->setEventId ($ newEventId )
184- ->setBelongsTo ($ question ->getBelongsTo ())
185- ->setType ($ question ->getType ())
186- ->setRequired ($ question ->getRequired ())
187- ->setOptions ($ question ->getOptions ())
188- ->setIsHidden ($ question ->getIsHidden ()),
189- array_map (
190- static fn (TicketDomainObject $ ticket ) => $ oldTicketToNewTicketMap [$ ticket ->getId ()],
191- $ question ->getTickets ()?->all(),
192- ),
193- );
185+ if ($ question ->getBelongsTo () === QuestionBelongsTo::TICKET ->name ) {
186+ $ this ->createQuestionService ->createQuestion (
187+ (new QuestionDomainObject ())
188+ ->setTitle ($ question ->getTitle ())
189+ ->setEventId ($ newEventId )
190+ ->setBelongsTo ($ question ->getBelongsTo ())
191+ ->setType ($ question ->getType ())
192+ ->setRequired ($ question ->getRequired ())
193+ ->setOptions ($ question ->getOptions ())
194+ ->setIsHidden ($ question ->getIsHidden ()),
195+ array_map (
196+ static fn (TicketDomainObject $ ticket ) => $ oldTicketToNewTicketMap [$ ticket ->getId ()],
197+ $ question ->getTickets ()?->all(),
198+ ),
199+ );
200+ }
201+ }
202+ }
203+
204+ /**
205+ * @throws Throwable
206+ */
207+ private function clonePerOrderQuestions (EventDomainObject $ event , int $ newEventId ): void
208+ {
209+ foreach ($ event ->getQuestions () as $ question ) {
210+ if ($ question ->getBelongsTo () === QuestionBelongsTo::ORDER ->name ) {
211+ $ this ->createQuestionService ->createQuestion (
212+ (new QuestionDomainObject ())
213+ ->setTitle ($ question ->getTitle ())
214+ ->setEventId ($ newEventId )
215+ ->setBelongsTo ($ question ->getBelongsTo ())
216+ ->setType ($ question ->getType ())
217+ ->setRequired ($ question ->getRequired ())
218+ ->setOptions ($ question ->getOptions ())
219+ ->setIsHidden ($ question ->getIsHidden ()),
220+ [],
221+ );
222+ }
194223 }
195224 }
196225
0 commit comments