Skip to content

Commit 25af7c7

Browse files
authored
Feature: Improve check in lists (#834)
1 parent 66e154e commit 25af7c7

File tree

51 files changed

+1356
-1243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1356
-1243
lines changed

backend/app/DomainObjects/AttendeeCheckInDomainObject.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class AttendeeCheckInDomainObject extends Generated\AttendeeCheckInDomainObjectA
66
{
77
private ?AttendeeDomainObject $attendee = null;
88

9+
private ?CheckInListDomainObject $checkInList = null;
10+
911
public function getAttendee(): ?AttendeeDomainObject
1012
{
1113
return $this->attendee;
@@ -16,4 +18,15 @@ public function setAttendee(AttendeeDomainObject $attendee): self
1618
$this->attendee = $attendee;
1719
return $this;
1820
}
21+
22+
public function setCheckInList(?CheckInListDomainObject $checkInList): AttendeeCheckInDomainObject
23+
{
24+
$this->checkInList = $checkInList;
25+
return $this;
26+
}
27+
28+
public function getCheckInList(): ?CheckInListDomainObject
29+
{
30+
return $this->checkInList;
31+
}
1932
}

backend/app/DomainObjects/AttendeeDomainObject.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class AttendeeDomainObject extends Generated\AttendeeDomainObjectAbstract implem
1818

1919
public ?AttendeeCheckInDomainObject $checkIn = null;
2020

21+
/** @var Collection<AttendeeCheckInDomainObject>|null */
22+
private ?Collection $checkIns = null;
23+
2124
public static function getDefaultSort(): string
2225
{
2326
return self::CREATED_AT;
@@ -108,8 +111,24 @@ public function setCheckIn(?AttendeeCheckInDomainObject $checkIn): AttendeeDomai
108111
return $this;
109112
}
110113

114+
/**
115+
* Only use in the context when a single check-in is expected (e.g., when loading a list of attendees for a specific check-in list).
116+
*
117+
* @return AttendeeCheckInDomainObject|null
118+
*/
111119
public function getCheckIn(): ?AttendeeCheckInDomainObject
112120
{
113121
return $this->checkIn;
114122
}
123+
124+
public function setCheckIns(?Collection $checkIns): AttendeeDomainObject
125+
{
126+
$this->checkIns = $checkIns;
127+
return $this;
128+
}
129+
130+
public function getCheckIns(): ?Collection
131+
{
132+
return $this->checkIns;
133+
}
115134
}

backend/app/Exports/AttendeesExport.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function headings(): array
5555
__('Last Name'),
5656
__('Email'),
5757
__('Status'),
58-
__('Is Checked In'),
59-
__('Checked In At'),
58+
__('Check Ins'),
6059
__('Product ID'),
6160
__('Product Name'),
6261
__('Event ID'),
@@ -106,16 +105,23 @@ public function map($attendee): array
106105
->getLabel();
107106
}
108107

108+
$checkIns = $attendee->getCheckIns()
109+
? $attendee->getCheckIns()
110+
->map(fn($checkIn) => sprintf(
111+
'%s (%s)',
112+
$checkIn->getCheckInList()?->getName() ?? __('Unknown'),
113+
Carbon::parse($checkIn->getCreatedAt())->format('Y-m-d H:i:s')
114+
))
115+
->join(', ')
116+
: '';
117+
109118
return array_merge([
110119
$attendee->getId(),
111120
$attendee->getFirstName(),
112121
$attendee->getLastName(),
113122
$attendee->getEmail(),
114123
$attendee->getStatus(),
115-
$attendee->getCheckIn() ? 'Yes' : 'No',
116-
$attendee->getCheckIn()
117-
? Carbon::parse($attendee->getCheckIn()->getCreatedAt())->format('Y-m-d H:i:s')
118-
: '',
124+
$checkIns,
119125
$attendee->getProductId(),
120126
$ticketName,
121127
$attendee->getEventId(),

backend/app/Http/Actions/Attendees/ExportAttendeesAction.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HiEvents\Http\Actions\Attendees;
44

55
use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
6+
use HiEvents\DomainObjects\CheckInListDomainObject;
67
use HiEvents\DomainObjects\Enums\QuestionBelongsTo;
78
use HiEvents\DomainObjects\EventDomainObject;
89
use HiEvents\DomainObjects\OrderDomainObject;
@@ -38,7 +39,13 @@ public function __invoke(int $eventId): BinaryFileResponse
3839
->loadRelation(QuestionAndAnswerViewDomainObject::class)
3940
->loadRelation(new Relationship(
4041
domainObject: AttendeeCheckInDomainObject::class,
41-
name: 'check_in',
42+
nested: [
43+
new Relationship(
44+
domainObject: CheckInListDomainObject::class,
45+
name: 'check_in_list',
46+
),
47+
],
48+
name: 'check_ins',
4249
))
4350
->loadRelation(new Relationship(
4451
domainObject: ProductDomainObject::class,

backend/app/Http/Actions/Attendees/GetAttendeeAction.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HiEvents\Http\Actions\Attendees;
44

55
use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
6+
use HiEvents\DomainObjects\CheckInListDomainObject;
67
use HiEvents\DomainObjects\EventDomainObject;
78
use HiEvents\DomainObjects\ProductDomainObject;
89
use HiEvents\DomainObjects\ProductPriceDomainObject;
@@ -38,7 +39,13 @@ public function __invoke(int $eventId, int $attendeeId): Response|JsonResponse
3839
], name: 'product'))
3940
->loadRelation(new Relationship(
4041
domainObject: AttendeeCheckInDomainObject::class,
41-
name: 'check_in',
42+
nested: [
43+
new Relationship(
44+
domainObject: CheckInListDomainObject::class,
45+
name: 'check_in_list',
46+
),
47+
],
48+
name: 'check_ins'
4249
))
4350
->findFirstWhere([
4451
'id' => $attendeeId,

backend/app/Http/Actions/BaseAction.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use Illuminate\Support\Collection;
2828
use Illuminate\Support\Facades\Auth;
2929
use Illuminate\Support\Facades\Response;
30-
use Spatie\LaravelData\Data;
3130

3231
abstract class BaseAction extends Controller
3332
{

backend/app/Http/Actions/CheckInLists/Public/GetCheckInListAttendeesPublicAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public function __construct(
1919
{
2020
}
2121

22-
public function __invoke(string $uuid, Request $request): JsonResponse
22+
public function __invoke(string $checkInListShortId, Request $request): JsonResponse
2323
{
2424
try {
2525
$attendees = $this->getCheckInListAttendeesPublicHandler->handle(
26-
shortId: $uuid,
26+
shortId: $checkInListShortId,
2727
queryParams: QueryParamsDTO::fromArray($request->query->all())
2828
);
2929
} catch (CannotCheckInException $e) {

backend/app/Models/Attendee.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function product(): BelongsTo
2828
return $this->belongsTo(Product::class);
2929
}
3030

31-
public function check_in(): HasOne
31+
public function check_ins(): HasMany
3232
{
33-
return $this->hasOne(AttendeeCheckIn::class);
33+
return $this->hasMany(AttendeeCheckIn::class);
3434
}
3535
}

backend/app/Models/AttendeeCheckIn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function products(): BelongsTo
1616
);
1717
}
1818

19-
public function checkInList(): BelongsTo
19+
public function check_in_list(): BelongsTo
2020
{
2121
return $this->belongsTo(CheckInList::class);
2222
}

backend/app/Repository/Eloquent/AttendeeRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function getAttendeesByCheckInShortId(string $shortId, QueryParamsDTO $pa
118118
->whereIn('attendees.status',[AttendeeStatus::ACTIVE->name, AttendeeStatus::CANCELLED->name, AttendeeStatus::AWAITING_PAYMENT->name])
119119
->whereIn('orders.status', [OrderStatus::COMPLETED->name, OrderStatus::AWAITING_OFFLINE_PAYMENT->name]);
120120

121-
$this->loadRelation(new Relationship(AttendeeCheckInDomainObject::class, name: 'check_in'));
121+
$this->loadRelation(new Relationship(AttendeeCheckInDomainObject::class, name: 'check_ins'));
122122

123123
return $this->simplePaginateWhere(
124124
where: $where,

0 commit comments

Comments
 (0)