@@ -79,6 +79,10 @@ public function duplicateEvent(
7979 cloneEventSettings: $ duplicateSettings ,
8080 );
8181
82+ if ($ duplicateQuestions ) {
83+ $ this ->clonePerOrderQuestions ($ event , $ newEvent ->getId ());
84+ }
85+
8286 if ($ duplicateTickets ) {
8387 $ this ->cloneExistingTickets (
8488 event: $ event ,
@@ -153,7 +157,7 @@ private function cloneExistingTickets(
153157 }
154158
155159 if ($ duplicateQuestions ) {
156- $ this ->cloneQuestions ($ event , $ newEventId , $ oldTicketToNewTicketMap );
160+ $ this ->clonePerTicketQuestions ($ event , $ newEventId , $ oldTicketToNewTicketMap );
157161 }
158162
159163 if ($ duplicatePromoCodes ) {
@@ -174,23 +178,47 @@ private function cloneExistingTickets(
174178 /**
175179 * @throws Throwable
176180 */
177- private function cloneQuestions (EventDomainObject $ event , int $ newEventId , array $ oldTicketToNewTicketMap ): void
181+ private function clonePerTicketQuestions (EventDomainObject $ event , int $ newEventId , array $ oldTicketToNewTicketMap ): void
178182 {
179183 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- );
184+ if ($ question ->getBelongsTo () == "TICKET " ) {
185+ $ this ->createQuestionService ->createQuestion (
186+ (new QuestionDomainObject ())
187+ ->setTitle ($ question ->getTitle ())
188+ ->setEventId ($ newEventId )
189+ ->setBelongsTo ($ question ->getBelongsTo ())
190+ ->setType ($ question ->getType ())
191+ ->setRequired ($ question ->getRequired ())
192+ ->setOptions ($ question ->getOptions ())
193+ ->setIsHidden ($ question ->getIsHidden ()),
194+ array_map (
195+ static fn (TicketDomainObject $ ticket ) => $ oldTicketToNewTicketMap [$ ticket ->getId ()],
196+ $ question ->getTickets ()?->all(),
197+ ),
198+ );
199+ }
200+ }
201+ }
202+
203+ /**
204+ * @throws Throwable
205+ */
206+ private function clonePerOrderQuestions (EventDomainObject $ event , int $ newEventId ): void
207+ {
208+ foreach ($ event ->getQuestions () as $ question ) {
209+ if ($ question ->getBelongsTo () == "ORDER " ) {
210+ $ this ->createQuestionService ->createQuestion (
211+ (new QuestionDomainObject ())
212+ ->setTitle ($ question ->getTitle ())
213+ ->setEventId ($ newEventId )
214+ ->setBelongsTo ($ question ->getBelongsTo ())
215+ ->setType ($ question ->getType ())
216+ ->setRequired ($ question ->getRequired ())
217+ ->setOptions ($ question ->getOptions ())
218+ ->setIsHidden ($ question ->getIsHidden ()),
219+ [],
220+ );
221+ }
194222 }
195223 }
196224
0 commit comments