Skip to content

Commit

Permalink
Add ticket name to export
Browse files Browse the repository at this point in the history
  • Loading branch information
daveearley committed Dec 20, 2024
1 parent 6dc8f68 commit 35c3374
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backend/app/Exports/AttendeesExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
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;
Expand Down Expand Up @@ -51,6 +54,7 @@ public function headings(): array
'Is Checked In',
'Checked In At',
'Ticket ID',
'Ticket Name',
'Event ID',
'Public ID',
'Short ID',
Expand All @@ -75,6 +79,16 @@ public function map($attendee): array
);
});

/** @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(),
Expand All @@ -86,6 +100,7 @@ public function map($attendee): array
? Carbon::parse($attendee->getCheckIn()->getCreatedAt())->format('Y-m-d H:i:s')
: '',
$attendee->getTicketId(),
$ticketName,
$attendee->getEventId(),
$attendee->getPublicId(),
$attendee->getShortId(),
Expand Down
11 changes: 11 additions & 0 deletions backend/app/Http/Actions/Attendees/ExportAttendeesAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
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;
Expand Down Expand Up @@ -37,6 +39,15 @@ public function __invoke(int $eventId): BinaryFileResponse
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([
Expand Down

0 comments on commit 35c3374

Please sign in to comment.