Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
remove unused classes
Dave Earleye1206d88dcec
diff --git a/backend/app/DataTransferObjects/BaseDTO.php b/backend/app/DataTransferObjects/BaseDTO.phpindex 687a3dbbe..caed0835a 100644--- a/backend/app/DataTransferObjects/BaseDTO.php+++ b/backend/app/DataTransferObjects/BaseDTO.php@@ -56,58 +56,6 @@ abstract class BaseDTOreturn collect(array_map([static::class, 'fromArray'], $items));}- /**- * Convert the DTO to a flattened array. Converts all enums to string and DTOs to arrays.- *- * It ain't pretty, but it works.- *- * @param array $without- * @return array- */- public function toFlattenedArray(array $without = []): array- {- $data = [];- $properties = get_object_vars($this);-- foreach ($properties as $key => $value) {- if (in_array($key, $without, true)) {- continue;- }-- if ($value instanceof self) {- $data[$key] = $value->toFlattenedArray();- } elseif ($value instanceof UnitEnum) {- $data[$key] = $value instanceof BackedEnum ? $value->value : $value->name;- } elseif ($value instanceof Collection) {- $data[$key] = $value->map(function ($item) {- if ($item instanceof BaseDTO) {- return $item->toFlattenedArray();- }-- if ($item instanceof UnitEnum) {- return $item instanceof BackedEnum ? $item->value : $item->name;- }- return $item;- })->toArray();- } elseif (is_array($value)) {- $data[$key] = array_map(static function ($item) {- if ($item instanceof BaseDTO) {- return $item->toFlattenedArray();- }-- if ($item instanceof UnitEnum) {- return $item instanceof BackedEnum ? $item->value : $item->name;- }- return $item;- }, $value);- } else {- $data[$key] = $value;- }- }-- return $data;- }-/*** Hydrate objects from properties based on property to object map.*diff --git a/backend/app/Services/Domain/Event/DTO/CreateEventDTO.php b/backend/app/Services/Domain/Event/DTO/CreateEventDTO.phpdeleted file mode 100644index 1fc88d3d1..000000000--- a/backend/app/Services/Domain/Event/DTO/CreateEventDTO.php+++ /dev/null@@ -1,13 +0,0 @@-<?php--namespace HiEvents\Services\Domain\Event\DTO;--use HiEvents\Services\Handlers\Event\DTO\CreateEventDTO as ApplicationCreateEventDTO;--/**- * This will always be identical to the CreateEventDTO in the Handlers namespace. So we can just extend it.- */-class CreateEventDTO extends ApplicationCreateEventDTO-{--}diff --git a/backend/app/Services/Domain/Event/DuplicateEventService.php b/backend/app/Services/Domain/Event/DuplicateEventService.phpindex 6e2094016..ca26381db 100644--- a/backend/app/Services/Domain/Event/DuplicateEventService.php+++ b/backend/app/Services/Domain/Event/DuplicateEventService.php@@ -13,7 +13,6 @@ use HiEvents\Repository\Interfaces\EventRepositoryInterface;use HiEvents\Services\Domain\PromoCode\CreatePromoCodeService;use HiEvents\Services\Domain\Question\CreateQuestionService;use HiEvents\Services\Domain\Ticket\CreateTicketService;-use Illuminate\Support\Collection;use Throwable;class DuplicateEventService@@ -90,9 +89,7 @@ class DuplicateEventService->setTimezone($event->getTimezone())->setCurrency($event->getCurrency())->setStatus($event->getStatus()),- eventSettings: $cloneEventSettings- ? $event->getEventSettings()- : null,+ eventSettings: $cloneEventSettings ? $event->getEventSettings() : null,);}@@ -108,58 +105,63 @@ class DuplicateEventService{$oldTicketToNewTicketMap = [];- $tickets = $event->getTickets();- foreach ($tickets as $ticket) {+ foreach ($event->getTickets() as $ticket) {$ticket->setEventId($newEventId);- $newTicket = $this->createTicketService->createTicket(- $ticket,- $event->getAccountId(),- );-+ $newTicket = $this->createTicketService->createTicket($ticket, $event->getAccountId());$oldTicketToNewTicketMap[$ticket->getId()] = $newTicket->getId();}if ($duplicateQuestions) {- /** @var Collection<QuestionDomainObject> $questions */- $questions = $event->getQuestions();-- foreach ($questions as $question) {- $this->createQuestionService->createQuestion(- (new QuestionDomainObject())- ->setTitle($question->getTitle())- ->setEventId($newEventId)- ->setBelongsTo($question->getBelongsTo())- ->setType($question->getType())- ->setRequired($question->getRequired())- ->setOptions($question->getOptions())- ->setIsHidden($question->getIsHidden()),- array_map(- static fn(TicketDomainObject $ticket) => $oldTicketToNewTicketMap[$ticket->getId()],- $question->getTickets()?->all(),- ),- );- }+ $this->cloneQuestions($event, $newEventId, $oldTicketToNewTicketMap);}if ($duplicatePromoCodes) {- /** @var Collection<PromoCodeDomainObject> $promoCodes */- $promoCodes = $event->getPromoCodes();-- foreach ($promoCodes as $promoCode) {- $this->createPromoCodeService->createPromoCode(- (new PromoCodeDomainObject())- ->setCode($promoCode->getCode())- ->setEventId($newEventId)- ->setApplicableTicketIds(array_map(- static fn($ticketId) => $oldTicketToNewTicketMap[$ticketId],- $promoCode->getApplicableTicketIds() ?? [],- ))- ->setDiscountType($promoCode->getDiscountType())- ->setDiscount($promoCode->getDiscount())- ->setExpiryDate($promoCode->getExpiryDate())- ->setMaxAllowedUsages($promoCode->getMaxAllowedUsages()),- );- }+ $this->clonePromoCodes($event, $newEventId, $oldTicketToNewTicketMap);+ }+ }++ /**+ * @throws Throwable+ */+ private function cloneQuestions(EventDomainObject $event, int $newEventId, array $oldTicketToNewTicketMap): void+ {+ foreach ($event->getQuestions() as $question) {+ $this->createQuestionService->createQuestion(+ (new QuestionDomainObject())+ ->setTitle($question->getTitle())+ ->setEventId($newEventId)+ ->setBelongsTo($question->getBelongsTo())+ ->setType($question->getType())+ ->setRequired($question->getRequired())+ ->setOptions($question->getOptions())+ ->setIsHidden($question->getIsHidden()),+ array_map(+ static fn(TicketDomainObject $ticket) => $oldTicketToNewTicketMap[$ticket->getId()],+ $question->getTickets()?->all(),+ ),+ );+ }+ }++ /**+ * @throws Throwable+ */+ private function clonePromoCodes(EventDomainObject $event, int $newEventId, array $oldTicketToNewTicketMap): void+ {+ foreach ($event->getPromoCodes() as $promoCode) {+ $this->createPromoCodeService->createPromoCode(+ (new PromoCodeDomainObject())+ ->setCode($promoCode->getCode())+ ->setEventId($newEventId)+ ->setApplicableTicketIds(array_map(+ static fn($ticketId) => $oldTicketToNewTicketMap[$ticketId],+ $promoCode->getApplicableTicketIds() ?? [],+ ))+ ->setDiscountType($promoCode->getDiscountType())+ ->setDiscount($promoCode->getDiscount())+ ->setExpiryDate($promoCode->getExpiryDate())+ ->setMaxAllowedUsages($promoCode->getMaxAllowedUsages()),+ );}}@@ -171,18 +173,12 @@ class DuplicateEventService->loadRelation(PromoCodeDomainObject::class)->loadRelation(new Relationship(domainObject: QuestionDomainObject::class,- nested: [- new Relationship(- domainObject: TicketDomainObject::class,- ),- ]))+ nested: [new Relationship(domainObject: TicketDomainObject::class)]+ ))->loadRelation(new Relationship(domainObject: TicketDomainObject::class,- nested: [- new Relationship(- domainObject: TicketPriceDomainObject::class,- ),- ]))+ nested: [new Relationship(domainObject: TicketPriceDomainObject::class)]+ ))->findFirstWhere(['id' => $eventId,'account_id' => $accountId,diff --git a/backend/app/Validators/EventRules.php b/backend/app/Validators/EventRules.phpindex 8528f1c92..a20812375 100644--- a/backend/app/Validators/EventRules.php+++ b/backend/app/Validators/EventRules.php@@ -34,9 +34,11 @@ trait EventRulesreturn ['title' => ['string', 'required', 'max:150', 'min:1'],'description' => ['string', 'min:1', 'max:50000', 'nullable'],- 'start_date' => ['date', 'required',- Rule::when($this->input('end_date') !== null,- ['before_or_equal:end_date'])],+ 'start_date' => [+ 'date',+ 'required',+ Rule::when($this->input('end_date') !== null, ['before_or_equal:end_date'])+ ],'end_date' => ['date', 'nullable'],];}