Skip to content

Commit 2f4afce

Browse files
committed
Merge branch 'develop' into console-error-cleanup
2 parents 7aed142 + 1470688 commit 2f4afce

File tree

3 files changed

+53
-17
lines changed

3 files changed

+53
-17
lines changed

backend/app/Services/Domain/Event/DuplicateEventService.php

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use HiEvents\DomainObjects\CapacityAssignmentDomainObject;
66
use HiEvents\DomainObjects\CheckInListDomainObject;
77
use HiEvents\DomainObjects\Enums\EventImageType;
8+
use HiEvents\DomainObjects\Enums\QuestionBelongsTo;
89
use HiEvents\DomainObjects\EventDomainObject;
910
use HiEvents\DomainObjects\EventSettingDomainObject;
1011
use 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

docker/all-in-one/.env

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
# See the README.md for informaiton on how to generate the JWT_SECRET and APP_KEY
1+
# See the README.md file for informaiton on how to generate the JWT_SECRET and APP_KEY
22
APP_KEY=
33
JWT_SECRET=
44

5+
# Frontend variables (Always prefixed with VITE_)
56
VITE_FRONTEND_URL=http://localhost:8123
67
VITE_API_URL_CLIENT=http://localhost:8123/api
78
VITE_API_URL_SERVER=http://localhost:80/api
89
VITE_STRIPE_PUBLISHABLE_KEY=pk_test
910

11+
# Backend variables
12+
# These values may not be suitable for production environments.
13+
# Please refer to the documentation for more information on how to configure these values
14+
# https://hi.events/docs/getting-started/deploying
1015
LOG_CHANNEL=stderr
1116
QUEUE_CONNECTION=sync
1217
MAIL_MAILER=log
@@ -15,5 +20,6 @@ FILESYSTEM_PUBLIC_DISK=public
1520
FILESYSTEM_PRIVATE_DISK=local
1621

1722
APP_CDN_URL=http://localhost:8123/storage
23+
APP_FRONTEND_URL=http://localhost:8123
1824

1925
DATABASE_URL=postgresql://postgres:secret@postgres:5432/hi-events

docker/all-in-one/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ services:
1515
- QUEUE_CONNECTION=${QUEUE_CONNECTION}
1616
- MAIL_MAILER=${MAIL_MAILER}
1717
- APP_KEY=${APP_KEY}
18+
- APP_FRONTEND_URL=${APP_FRONTEND_URL}
1819
- JWT_SECRET=${JWT_SECRET}
1920
- FILESYSTEM_PUBLIC_DISK=${FILESYSTEM_PUBLIC_DISK}
2021
- FILESYSTEM_PRIVATE_DISK=${FILESYSTEM_PRIVATE_DISK}

0 commit comments

Comments
 (0)