-
-
Notifications
You must be signed in to change notification settings - Fork 663
Expand file tree
/
Copy pathCheckInListDomainObject.php
More file actions
157 lines (124 loc) · 3.9 KB
/
Copy pathCheckInListDomainObject.php
File metadata and controls
157 lines (124 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
namespace HiEvents\DomainObjects;
use Carbon\Carbon;
use HiEvents\DomainObjects\Interfaces\IsSortable;
use HiEvents\DomainObjects\SortingAndFiltering\AllowedSorts;
use Illuminate\Support\Collection;
/**
* A `null` event_occurrence_id means the list applies to every occurrence of the
* event (the default for recurring events and the only meaningful value for
* single-occurrence events). A non-null value scopes the list to that one
* occurrence — only attendees on that occurrence can be checked in via the list.
*/
class CheckInListDomainObject extends Generated\CheckInListDomainObjectAbstract implements IsSortable
{
private ?Collection $products = null;
private ?EventDomainObject $event = null;
private ?EventOccurrenceDomainObject $eventOccurrence = null;
private ?int $checkedInCount = null;
private ?int $totalAttendeesCount = null;
private ?string $timezone = null;
public static function getDefaultSort(): string
{
return static::CREATED_AT;
}
public static function getDefaultSortDirection(): string
{
return 'desc';
}
public static function getAllowedSorts(): AllowedSorts
{
return new AllowedSorts(
[
self::NAME => [
'asc' => __('Name A-Z'),
'desc' => __('Name Z-A'),
],
self::EXPIRES_AT => [
'asc' => __('Expires soonest'),
'desc' => __('Expires latest'),
],
self::CREATED_AT => [
'asc' => __('Oldest first'),
'desc' => __('Newest first'),
],
self::UPDATED_AT => [
'asc' => __('Updated oldest first'),
'desc' => __('Updated newest first'),
],
]
);
}
public function getProducts(): ?Collection
{
return $this->products;
}
public function setProducts(?Collection $products): static
{
$this->products = $products;
return $this;
}
public function getEvent(): ?EventDomainObject
{
return $this->event;
}
public function setEvent(?EventDomainObject $event): static
{
$this->event = $event;
return $this;
}
public function getEventOccurrence(): ?EventOccurrenceDomainObject
{
return $this->eventOccurrence;
}
public function setEventOccurrence(?EventOccurrenceDomainObject $eventOccurrence): static
{
$this->eventOccurrence = $eventOccurrence;
return $this;
}
public function isExpired(string $timezone): bool
{
if ($this->getExpiresAt() === null) {
return false;
}
$endDate = Carbon::parse($this->getExpiresAt());
$endDate->setTimezone($timezone);
return $endDate->isPast();
}
public function isActivated(string $timezone): bool
{
if ($this->getActivatesAt() === null) {
return true;
}
$startDate = Carbon::parse($this->getActivatesAt());
$startDate->setTimezone($timezone);
return $startDate->isPast();
}
public function getCheckedInCount(): ?int
{
return $this->checkedInCount;
}
public function setCheckedInCount(?int $checkedInCount): static
{
$this->checkedInCount = $checkedInCount ?? 0;
return $this;
}
public function getTotalAttendeesCount(): ?int
{
return $this->totalAttendeesCount;
}
public function setTotalAttendeesCount(?int $totalAttendeesCount): static
{
$this->totalAttendeesCount = $totalAttendeesCount ?? 0;
return $this;
}
public function getTimezone(): ?string
{
return $this->timezone;
}
public function setTimezone(?string $timezone): static
{
$this->timezone = $timezone;
return $this;
}
}