Skip to content

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 ⭐️

Add ticket name to export

Dave Earley35c33744417a
diff --git a/backend/app/Exports/AttendeesExport.php b/backend/app/Exports/AttendeesExport.php
index 54e11a6e7..7f5d0d42d 100644
--- a/backend/app/Exports/AttendeesExport.php
+++ b/backend/app/Exports/AttendeesExport.php
@@ -5,7 +5,10 @@ namespace HiEvents\Exports;
use Carbon\Carbon;
use HiEvents\DomainObjects\AttendeeDomainObject;
use HiEvents\DomainObjects\Enums\QuestionTypeEnum;
+use HiEvents\DomainObjects\Enums\TicketType;
use HiEvents\DomainObjects\QuestionDomainObject;
+use HiEvents\DomainObjects\TicketDomainObject;
+use HiEvents\DomainObjects\TicketPriceDomainObject;
use HiEvents\Resources\Attendee\AttendeeResource;
use HiEvents\Services\Domain\Question\QuestionAnswerFormatter;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
@@ -51,6 +54,7 @@ class AttendeesExport implements FromCollection, WithHeadings, WithMapping, With
'Is Checked In',
'Checked In At',
'Ticket ID',
+ 'Ticket Name',
'Event ID',
'Public ID',
'Short ID',
@@ -75,6 +79,16 @@ class AttendeesExport implements FromCollection, WithHeadings, WithMapping, With
);
});
+ /** @var TicketDomainObject $ticket */
+ $ticket = $attendee->getTicket();
+ $ticketName = $ticket->getTitle();
+ if ($attendee->getTicket()?->getType() === TicketType::TIERED->name) {
+ $ticketName .= ' - ' . $ticket
+ ->getTicketPrices()
+ ->first(fn(TicketPriceDomainObject $tp) => $tp->getId() === $attendee->getTicketPriceId())
+ ->getLabel();
+ }
+
return array_merge([
$attendee->getId(),
$attendee->getFirstName(),
@@ -86,6 +100,7 @@ class AttendeesExport implements FromCollection, WithHeadings, WithMapping, With
? Carbon::parse($attendee->getCheckIn()->getCreatedAt())->format('Y-m-d H:i:s')
: '',
$attendee->getTicketId(),
+ $ticketName,
$attendee->getEventId(),
$attendee->getPublicId(),
$attendee->getShortId(),
diff --git a/backend/app/Http/Actions/Attendees/ExportAttendeesAction.php b/backend/app/Http/Actions/Attendees/ExportAttendeesAction.php
index 356792393..729b5c8a5 100644
--- a/backend/app/Http/Actions/Attendees/ExportAttendeesAction.php
+++ b/backend/app/Http/Actions/Attendees/ExportAttendeesAction.php
@@ -6,6 +6,8 @@ use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
use HiEvents\DomainObjects\Enums\QuestionBelongsTo;
use HiEvents\DomainObjects\EventDomainObject;
use HiEvents\DomainObjects\QuestionAndAnswerViewDomainObject;
+use HiEvents\DomainObjects\TicketDomainObject;
+use HiEvents\DomainObjects\TicketPriceDomainObject;
use HiEvents\Exports\AttendeesExport;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Repository\Eloquent\Value\Relationship;
@@ -37,6 +39,15 @@ class ExportAttendeesAction extends BaseAction
domainObject: AttendeeCheckInDomainObject::class,
name: 'check_in',
))
+ ->loadRelation(new Relationship(
+ domainObject: TicketDomainObject::class,
+ nested: [
+ new Relationship(
+ domainObject: TicketPriceDomainObject::class,
+ ),
+ ],
+ name: 'ticket'
+ ))
->findByEventIdForExport($eventId);
$questions = $this->questionRepository->findWhere([