PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.11
Booking for Appointments and Events Calendar – Amelia v1.2.11
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Domain / Factory / Booking / Event / EventFactory.php
ameliabooking / src / Domain / Factory / Booking / Event Last commit date
CustomerBookingEventPeriodFactory.php 7 years ago CustomerBookingEventTicketFactory.php 4 years ago EventFactory.php 1 year ago EventPeriodFactory.php 4 years ago EventTagFactory.php 7 years ago EventTicketFactory.php 1 year ago RecurringFactory.php 5 years ago
EventFactory.php
577 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace AmeliaBooking\Domain\Factory\Booking\Event;
8
9 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
10 use AmeliaBooking\Domain\Entity\Booking\Event\Event;
11 use AmeliaBooking\Domain\Entity\Entities;
12 use AmeliaBooking\Domain\Entity\Gallery\GalleryImage;
13 use AmeliaBooking\Domain\Factory\Booking\Appointment\CustomerBookingFactory;
14 use AmeliaBooking\Domain\Factory\Coupon\CouponFactory;
15 use AmeliaBooking\Domain\Factory\User\ProviderFactory;
16 use AmeliaBooking\Domain\Services\DateTime\DateTimeService;
17 use AmeliaBooking\Domain\ValueObjects\BooleanValueObject;
18 use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue;
19 use AmeliaBooking\Domain\ValueObjects\Json;
20 use AmeliaBooking\Domain\ValueObjects\Number\Float\Price;
21 use AmeliaBooking\Domain\ValueObjects\Number\Integer\IntegerValue;
22 use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger;
23 use AmeliaBooking\Domain\ValueObjects\Picture;
24 use AmeliaBooking\Domain\ValueObjects\String\BookingStatus;
25 use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id;
26 use AmeliaBooking\Domain\Collection\Collection;
27 use AmeliaBooking\Domain\ValueObjects\String\Color;
28 use AmeliaBooking\Domain\ValueObjects\String\DepositType;
29 use AmeliaBooking\Domain\ValueObjects\String\Description;
30 use AmeliaBooking\Domain\ValueObjects\String\EntityType;
31 use AmeliaBooking\Domain\ValueObjects\String\Name;
32 use AmeliaBooking\Infrastructure\Licence;
33
34 /**
35 * Class EventFactory
36 *
37 * @package AmeliaBooking\Domain\Factory\Booking\Event
38 */
39 class EventFactory
40 {
41
42 /**
43 * @param $data
44 *
45 * @return Event
46 * @throws InvalidArgumentException
47 */
48 public static function create($data)
49 {
50 Licence\DataModifier::eventFactory($data);
51
52 $event = new Event();
53
54 if (isset($data['id'])) {
55 $event->setId(new Id($data['id']));
56 }
57
58 if (isset($data['name'])) {
59 $event->setName(new Name($data['name']));
60 }
61
62 if (isset($data['price'])) {
63 $event->setPrice(new Price($data['price']));
64 }
65
66 if (isset($data['parentId'])) {
67 $event->setParentId(new Id($data['parentId']));
68 }
69
70 if (!empty($data['bookingOpens'])) {
71 $event->setBookingOpens(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingOpens'])));
72 }
73
74 if (!empty($data['bookingCloses'])) {
75 $event->setBookingCloses(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['bookingCloses'])));
76 }
77
78 if (!empty($data['bookingOpensRec'])) {
79 $event->setBookingOpensRec($data['bookingOpensRec']);
80 }
81
82 if (!empty($data['bookingClosesRec'])) {
83 $event->setBookingClosesRec($data['bookingClosesRec']);
84 }
85
86 if (!empty($data['ticketRangeRec'])) {
87 $event->setTicketRangeRec($data['ticketRangeRec']);
88 }
89
90 if (isset($data['notifyParticipants'])) {
91 $event->setNotifyParticipants($data['notifyParticipants']);
92 }
93
94 if (isset($data['status'])) {
95 $event->setStatus(new BookingStatus($data['status']));
96 }
97
98 if (isset($data['recurring']['cycle'], $data['recurring']['until'])) {
99 $event->setRecurring(RecurringFactory::create($data['recurring']));
100 }
101
102 if (isset($data['bringingAnyone'])) {
103 $event->setBringingAnyone(new BooleanValueObject($data['bringingAnyone']));
104 }
105
106 if (isset($data['bookMultipleTimes'])) {
107 $event->setBookMultipleTimes(new BooleanValueObject($data['bookMultipleTimes']));
108 }
109
110 if (isset($data['maxCapacity'])) {
111 $event->setMaxCapacity(new IntegerValue($data['maxCapacity']));
112 }
113
114 if (isset($data['maxCustomCapacity'])) {
115 $event->setMaxCustomCapacity(new IntegerValue($data['maxCustomCapacity']));
116 }
117
118 if (isset($data['description'])) {
119 $event->setDescription(new Description($data['description']));
120 }
121
122 if (!empty($data['locationId'])) {
123 $event->setLocationId(new Id($data['locationId']));
124 }
125
126 if (!empty($data['customLocation'])) {
127 $event->setCustomLocation(new Name($data['customLocation']));
128 }
129
130 if (isset($data['color'])) {
131 $event->setColor(new Color($data['color']));
132 }
133
134 if (isset($data['show'])) {
135 $event->setShow(new BooleanValueObject($data['show']));
136 }
137
138 if (isset($data['created'])) {
139 $event->setCreated(new DateTimeValue(DateTimeService::getCustomDateTimeObject($data['created'])));
140 }
141
142 if (!empty($data['settings'])) {
143 $event->setSettings(new Json($data['settings']));
144 }
145
146 if (isset($data['deposit'])) {
147 $event->setDeposit(new Price($data['deposit']));
148 }
149
150 if (isset($data['depositPayment'])) {
151 $event->setDepositPayment(new DepositType($data['depositPayment']));
152 }
153
154 if (isset($data['fullPayment'])) {
155 $event->setFullPayment(new BooleanValueObject($data['fullPayment']));
156 }
157
158 if (isset($data['customPricing'])) {
159 $event->setCustomPricing(new BooleanValueObject($data['customPricing']));
160 }
161
162 if (isset($data['depositPerPerson'])) {
163 $event->setDepositPerPerson(new BooleanValueObject($data['depositPerPerson']));
164 }
165
166 if (isset($data['closeAfterMin'])) {
167 $event->setCloseAfterMin(new IntegerValue($data['closeAfterMin']));
168 }
169
170 if (isset($data['closeAfterMinBookings'])) {
171 $event->setCloseAfterMinBookings(new BooleanValueObject($data['closeAfterMinBookings']));
172 }
173
174 if (isset($data['aggregatedPrice'])) {
175 $event->setAggregatedPrice(new BooleanValueObject($data['aggregatedPrice']));
176 }
177
178
179 if (isset($data['maxExtraPeople'])) {
180 $event->setMaxExtraPeople(new IntegerValue($data['maxExtraPeople']));
181 }
182
183 $tickets = new Collection();
184
185 if (isset($data['customTickets'])) {
186 foreach ($data['customTickets'] as $key => $value) {
187 $tickets->addItem(
188 EventTicketFactory::create($value),
189 $key
190 );
191 }
192 }
193
194 $event->setCustomTickets($tickets);
195
196 $tags = new Collection();
197
198 if (isset($data['tags'])) {
199 foreach ((array)$data['tags'] as $key => $value) {
200 $tags->addItem(
201 EventTagFactory::create($value),
202 $key
203 );
204 }
205 }
206
207 $event->setTags($tags);
208
209 $bookings = new Collection();
210
211 if (isset($data['bookings'])) {
212 foreach ((array)$data['bookings'] as $key => $value) {
213 $bookings->addItem(
214 CustomerBookingFactory::create($value),
215 $key
216 );
217 }
218 }
219
220 $event->setBookings($bookings);
221
222 $periods = new Collection();
223
224 if (isset($data['periods'])) {
225 foreach ((array)$data['periods'] as $key => $value) {
226 $periods->addItem(EventPeriodFactory::create($value));
227 }
228 }
229
230 $event->setPeriods($periods);
231
232 $gallery = new Collection();
233
234 if (!empty($data['gallery'])) {
235 foreach ((array)$data['gallery'] as $image) {
236 $galleryImage = new GalleryImage(
237 new EntityType(Entities::EVENT),
238 new Picture($image['pictureFullPath'], $image['pictureThumbPath']),
239 new PositiveInteger($image['position'])
240 );
241
242 if (!empty($image['id'])) {
243 $galleryImage->setId(new Id($image['id']));
244 }
245
246 if ($event->getId()) {
247 $galleryImage->setEntityId($event->getId());
248 }
249
250 $gallery->addItem($galleryImage);
251 }
252 }
253
254 $event->setGallery($gallery);
255
256 $coupons = new Collection();
257
258 if (!empty($data['coupons'])) {
259 /** @var array $couponsList */
260 $couponsList = $data['coupons'];
261
262 foreach ($couponsList as $couponKey => $coupon) {
263 $coupons->addItem(CouponFactory::create($coupon), $couponKey);
264 }
265 }
266
267 $event->setCoupons($coupons);
268
269 $providers = new Collection();
270
271 if (!empty($data['providers'])) {
272 /** @var array $providerList */
273 $providerList = $data['providers'];
274
275 foreach ($providerList as $providerKey => $provider) {
276 $providers->addItem(ProviderFactory::create($provider), $providerKey);
277 }
278 }
279
280 if (!empty($data['organizerId'])) {
281 $event->setOrganizerId(new Id($data['organizerId']));
282 }
283
284 $event->setProviders($providers);
285
286 if (!empty($data['zoomUserId'])) {
287 $event->setZoomUserId(new Name($data['zoomUserId']));
288 }
289
290 if (!empty($data['translations'])) {
291 $event->setTranslations(new Json($data['translations']));
292 }
293
294 return $event;
295 }
296
297 /**
298 * @param array $rows
299 *
300 * @return Collection
301 * @throws InvalidArgumentException
302 */
303 public static function createCollection($rows)
304 {
305 $events = [];
306
307 foreach ($rows as $row) {
308 $eventId = $row['event_id'];
309 $eventPeriodId = isset($row['event_periodId']) ? $row['event_periodId'] : null;
310 $galleryId = isset($row['gallery_id']) ? $row['gallery_id'] : null;
311 $customerId = isset($row['customer_id']) ? $row['customer_id'] : null;
312 $bookingId = isset($row['booking_id']) ? $row['booking_id'] : null;
313 $bookingTicketId = isset($row['booking_ticket_id']) ? $row['booking_ticket_id'] : null;
314 $paymentId = isset($row['payment_id']) ? $row['payment_id'] : null;
315 $tagId = isset($row['event_tagId']) ? $row['event_tagId'] : null;
316 $ticketId = isset($row['ticket_id']) ? $row['ticket_id'] : null;
317 $providerId = isset($row['provider_id']) ? $row['provider_id'] : null;
318 $couponId = isset($row['coupon_id']) ? $row['coupon_id'] : null;
319
320 if (!array_key_exists($eventId, $events)) {
321 $events[$eventId] = [
322 'id' => $eventId,
323 'name' => $row['event_name'],
324 'status' => $row['event_status'],
325 'bookingOpens' => $row['event_bookingOpens'] && $row['event_bookingOpens'] !== '0000-00-00 00:00:00' ?
326 DateTimeService::getCustomDateTimeFromUtc($row['event_bookingOpens']) : null,
327 'bookingCloses' => $row['event_bookingCloses'] && $row['event_bookingCloses'] !== '0000-00-00 00:00:00' ?
328 DateTimeService::getCustomDateTimeFromUtc($row['event_bookingCloses']) : null,
329 'bookingOpensRec' => isset($row['event_bookingOpensRec']) ?
330 $row['event_bookingOpensRec'] : null,
331 'bookingClosesRec' => isset($row['event_bookingClosesRec']) ?
332 $row['event_bookingClosesRec'] : null,
333 'ticketRangeRec' => isset($row['event_ticketRangeRec']) ?
334 $row['event_ticketRangeRec'] : null,
335 'recurring' => [
336 'cycle' => $row['event_recurringCycle'],
337 'order' => $row['event_recurringOrder'],
338 'cycleInterval' => $row['event_recurringInterval'],
339 'monthlyRepeat' => isset($row['event_recurringMonthly']) ? $row['event_recurringMonthly'] : null,
340 'monthDate' => !empty($row['event_monthlyDate']) && $row['event_monthlyDate'] !== '0000-00-00 00:00:00' ?
341 DateTimeService::getCustomDateTimeFromUtc($row['event_monthlyDate']) : null,
342 'monthlyOnRepeat' => isset($row['event_monthlyOnRepeat']) ? $row['event_monthlyOnRepeat'] : null,
343 'monthlyOnDay' => isset($row['event_monthlyOnDay']) ? $row['event_monthlyOnDay'] : null,
344 'until' => !empty($row['event_recurringUntil']) && $row['event_recurringUntil'] !== '0000-00-00 00:00:00' ?
345 DateTimeService::getCustomDateTimeFromUtc($row['event_recurringUntil']) : null,
346 ],
347 'bringingAnyone' => $row['event_bringingAnyone'],
348 'bookMultipleTimes' => $row['event_bookMultipleTimes'],
349 'maxCapacity' => !empty($row['event_maxCapacity']) ? $row['event_maxCapacity'] : null,
350 'maxCustomCapacity' => !empty($row['event_maxCustomCapacity']) ? $row['event_maxCustomCapacity'] : null,
351 'maxExtraPeople' => !empty($row['event_maxExtraPeople']) ? $row['event_maxExtraPeople'] : null,
352 'price' => $row['event_price'],
353 'description' => $row['event_description'],
354 'color' => $row['event_color'],
355 'show' => $row['event_show'],
356 'notifyParticipants' => $row['event_notifyParticipants'],
357 'locationId' => $row['event_locationId'],
358 'customLocation' => $row['event_customLocation'],
359 'parentId' => $row['event_parentId'],
360 'created' => $row['event_created'],
361 'settings' => isset($row['event_settings']) ? $row['event_settings'] : null,
362 'zoomUserId' => isset($row['event_zoomUserId']) ? $row['event_zoomUserId'] : null,
363 'organizerId' => isset($row['event_organizerId']) ? $row['event_organizerId'] : null,
364 'translations' => isset($row['event_translations']) ? $row['event_translations'] : null,
365 'deposit' => isset($row['event_deposit']) ? $row['event_deposit'] : null,
366 'depositPayment' => isset($row['event_depositPayment']) ?
367 $row['event_depositPayment'] : null,
368 'depositPerPerson' => isset($row['event_depositPerPerson']) ?
369 $row['event_depositPerPerson'] : null,
370 'fullPayment' => isset($row['event_fullPayment']) ?
371 $row['event_fullPayment'] : null,
372 'customPricing' => isset($row['event_customPricing']) ?
373 $row['event_customPricing'] : null,
374 'closeAfterMin' => isset($row['event_closeAfterMin']) ? $row['event_closeAfterMin'] : null,
375 'closeAfterMinBookings' => isset($row['event_closeAfterMinBookings']) ? $row['event_closeAfterMinBookings'] : null,
376 'aggregatedPrice' => isset($row['event_aggregatedPrice']) ? $row['event_aggregatedPrice'] : null,
377 ];
378 }
379
380 if ($galleryId) {
381 $events[$eventId]['gallery'][$galleryId]['id'] = $row['gallery_id'];
382 $events[$eventId]['gallery'][$galleryId]['pictureFullPath'] = $row['gallery_picture_full'];
383 $events[$eventId]['gallery'][$galleryId]['pictureThumbPath'] = $row['gallery_picture_thumb'];
384 $events[$eventId]['gallery'][$galleryId]['position'] = $row['gallery_position'];
385 }
386
387 if ($providerId) {
388 $events[$eventId]['providers'][$providerId] =
389 [
390 'id' => $providerId,
391 'firstName' => $row['provider_firstName'],
392 'lastName' => $row['provider_lastName'],
393 'email' => $row['provider_email'],
394 'note' => $row['provider_note'],
395 'description' => $row['provider_description'],
396 'phone' => $row['provider_phone'],
397 'pictureFullPath' =>
398 isset($row['provider_pictureFullPath']) ? $row['provider_pictureFullPath'] : null,
399 'pictureThumbPath' =>
400 isset($row['provider_pictureFullPath']) ? $row['provider_pictureThumbPath'] : null,
401 'type' => 'provider',
402 'googleCalendar' => [
403 'id' => isset($row['google_calendar_id']) ? $row['google_calendar_id'] : null,
404 'token' => isset($row['google_calendar_token']) ? $row['google_calendar_token'] : null,
405 'calendarId' => isset($row['google_calendar_calendar_id']) ? $row['google_calendar_calendar_id'] : null
406 ],
407 'translations' => $row['provider_translations'],
408 'timeZone' => isset($row['provider_timeZone']) ? $row['provider_timeZone'] : null,
409 'outlookCalendar' => [
410 'id' => isset($row['outlook_calendar_id']) ? $row['outlook_calendar_id']: null,
411 'token' => isset($row['outlook_calendar_token']) ? $row['outlook_calendar_token'] : null,
412 'calendarId' => isset($row['outlook_calendar_calendar_id']) ? $row['outlook_calendar_calendar_id'] : null
413 ],
414 ];
415 }
416
417
418 if ($eventPeriodId && !isset($events[$eventId]['periods'][$eventPeriodId])) {
419 $zoomMeetingJson = !empty($row['event_periodZoomMeeting']) ?
420 json_decode($row['event_periodZoomMeeting'], true) : null;
421
422 $events[$eventId]['periods'][$eventPeriodId] = [
423 'id' => $eventPeriodId,
424 'eventId' => $eventId,
425 'periodStart' => DateTimeService::getCustomDateTimeFromUtc($row['event_periodStart']),
426 'periodEnd' => DateTimeService::getCustomDateTimeFromUtc($row['event_periodEnd']),
427 'zoomMeeting' => [
428 'id' => $zoomMeetingJson ? $zoomMeetingJson['id'] : null,
429 'startUrl' => $zoomMeetingJson ? $zoomMeetingJson['startUrl'] : null,
430 'joinUrl' => $zoomMeetingJson ? $zoomMeetingJson['joinUrl'] : null,
431 ],
432 'lessonSpace' => !empty($row['event_periodLessonSpace']) ?
433 $row['event_periodLessonSpace'] : null,
434 'bookings' => [],
435 'googleCalendarEventId' => !empty($row['event_googleCalendarEventId']) ?
436 $row['event_googleCalendarEventId'] : null,
437 'googleMeetUrl' => !empty($row['event_googleMeetUrl']) ?
438 $row['event_googleMeetUrl'] : null,
439 'outlookCalendarEventId' => !empty($row['event_outlookCalendarEventId']) ?
440 $row['event_outlookCalendarEventId'] : null
441 ];
442 }
443
444 if ($tagId && !isset($events[$eventId]['tags'][$tagId])) {
445 $events[$eventId]['tags'][$tagId] = [
446 'id' => $tagId,
447 'eventId' => $eventId,
448 'name' => $row['event_tagName']
449 ];
450 }
451
452 if ($bookingId && !isset($events[$eventId]['bookings'][$bookingId])) {
453 $events[$eventId]['bookings'][$bookingId] = [
454 'id' => $bookingId,
455 'appointmentId' => null,
456 'customerId' => $row['booking_customerId'],
457 'status' => $row['booking_status'],
458 'price' => $row['booking_price'],
459 'persons' => $row['booking_persons'],
460 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null,
461 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null,
462 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null,
463 'aggregatedPrice' => isset($row['booking_aggregatedPrice']) ?
464 $row['booking_aggregatedPrice'] : null,
465 'token' => isset($row['booking_token']) ? $row['booking_token'] : null,
466 'created' => !empty($row['booking_created']) ? DateTimeService::getCustomDateTimeFromUtc($row['booking_created']) : null,
467 'tax' => isset($row['booking_tax']) ? $row['booking_tax'] : null,
468 ];
469 }
470
471 if ($bookingTicketId && !isset($events[$eventId]['bookings'][$bookingId]['ticketsData'][$bookingTicketId])) {
472 $events[$eventId]['bookings'][$bookingId]['ticketsData'][$bookingTicketId] = [
473 'id' => $bookingTicketId,
474 'eventTicketId' => $row['booking_ticket_eventTicketId'],
475 'customerBookingId' => $bookingId,
476 'persons' => $row['booking_ticket_persons'],
477 'price' => $row['booking_ticket_price'],
478 ];
479 }
480
481 if ($ticketId && !isset($events[$eventId]['customTickets'][$ticketId])) {
482 $events[$eventId]['customTickets'][$ticketId] = [
483 'id' => $ticketId,
484 'eventId' => $eventId,
485 'name' => $row['ticket_name'],
486 'enabled' => $row['ticket_enabled'],
487 'spots' => $row['ticket_spots'],
488 'waitingListSpots' => !empty($row['ticket_waiting_list_spots']) ? $row['ticket_waiting_list_spots'] : null,
489 'price' => $row['ticket_price'],
490 'dateRanges' => $row['ticket_dateRanges'],
491 'translations' => $row['ticket_translations'],
492 ];
493 }
494
495 if ($bookingId && !isset($events[$eventId]['periods'][$eventPeriodId]['bookings'][$bookingId])) {
496 $events[$eventId]['periods'][$eventPeriodId]['bookings'][$bookingId] = [
497 'id' => $bookingId,
498 'appointmentId' => null,
499 'customerId' => $row['booking_customerId'],
500 'status' => $row['booking_status'],
501 'price' => $row['booking_price'],
502 'persons' => $row['booking_persons'],
503 'customFields' => !empty($row['booking_customFields']) ? $row['booking_customFields'] : null,
504 'info' => !empty($row['booking_info']) ? $row['booking_info'] : null,
505 'utcOffset' => isset($row['booking_utcOffset']) ? $row['booking_utcOffset'] : null
506 ];
507 }
508
509 if ($bookingId && $paymentId) {
510 $events[$eventId]['bookings'][$bookingId]['payments'][$paymentId] =
511 [
512 'id' => $paymentId,
513 'customerBookingId' => $bookingId,
514 'status' => $row['payment_status'],
515 'dateTime' => DateTimeService::getCustomDateTimeFromUtc($row['payment_dateTime']),
516 'gateway' => $row['payment_gateway'],
517 'gatewayTitle' => $row['payment_gatewayTitle'],
518 'transactionId' => !empty($row['payment_transactionId']) ? $row['payment_transactionId'] : null,
519 'parentId' => !empty($row['payment_parentId']) ? $row['payment_parentId'] : null,
520 'amount' => $row['payment_amount'],
521 'data' => $row['payment_data'],
522 'wcOrderId' => !empty($row['payment_wcOrderId']) ? $row['payment_wcOrderId'] : null,
523 'wcOrderItemId' => !empty($row['payment_wcOrderItemId']) ?
524 $row['payment_wcOrderItemId'] : null,
525 'invoiceNumber' => !empty($row['payment_invoiceNumber']) ? $row['payment_invoiceNumber'] : null,
526 ];
527 }
528
529 if ($bookingId && $customerId) {
530 $events[$eventId]['bookings'][$bookingId]['customer'] =
531 [
532 'id' => $customerId,
533 'firstName' => $row['customer_firstName'],
534 'lastName' => $row['customer_lastName'],
535 'email' => $row['customer_email'],
536 'note' => $row['customer_note'],
537 'phone' => $row['customer_phone'],
538 'gender' => $row['customer_gender'],
539 'birthday' => !empty($row['customer_birthday']) ? $row['customer_birthday'] : null,
540 'type' => 'customer',
541 ];
542 }
543
544 if ($bookingId && $couponId) {
545 $events[$eventId]['bookings'][$bookingId]['coupon']['id'] = $couponId;
546 $events[$eventId]['bookings'][$bookingId]['coupon']['code'] = $row['coupon_code'];
547 $events[$eventId]['bookings'][$bookingId]['coupon']['discount'] = $row['coupon_discount'];
548 $events[$eventId]['bookings'][$bookingId]['coupon']['deduction'] = $row['coupon_deduction'];
549 $events[$eventId]['bookings'][$bookingId]['coupon']['limit'] = $row['coupon_limit'];
550 $events[$eventId]['bookings'][$bookingId]['coupon']['customerLimit'] = $row['coupon_customerLimit'];
551 $events[$eventId]['bookings'][$bookingId]['coupon']['status'] = $row['coupon_status'];
552 }
553
554 if ($couponId) {
555 $events[$eventId]['coupons'][$couponId]['id'] = $couponId;
556 $events[$eventId]['coupons'][$couponId]['code'] = $row['coupon_code'];
557 $events[$eventId]['coupons'][$couponId]['discount'] = $row['coupon_discount'];
558 $events[$eventId]['coupons'][$couponId]['deduction'] = $row['coupon_deduction'];
559 $events[$eventId]['coupons'][$couponId]['limit'] = $row['coupon_limit'];
560 $events[$eventId]['coupons'][$couponId]['customerLimit'] = $row['coupon_customerLimit'];
561 $events[$eventId]['coupons'][$couponId]['status'] = $row['coupon_status'];
562 }
563 }
564
565 $collection = new Collection();
566
567 foreach ($events as $key => $value) {
568 $collection->addItem(
569 self::create($value),
570 $key
571 );
572 }
573
574 return $collection;
575 }
576 }
577