PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.1.0
GiveWP – Donation Plugin and Fundraising Platform v4.1.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / EventTickets / ViewModels / EventDetails.php
EventDetails.php
49 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\EventTickets\ViewModels;
4
5 use Give\DonationForms\Models\DonationForm;
6 use Give\EventTickets\Actions\AttachAttendeeDataToTicketData;
7 use Give\EventTickets\DataTransferObjects\EventTicketTypeData;
8 use Give\EventTickets\Models\Event;
9 use Give\EventTickets\Models\EventTicketType;
10
11 /**
12 * @since 3.6.0
13 */
14 class EventDetails
15 {
16
17 /**
18 * @since 3.6.0
19 * @var Event
20 */
21 protected $event;
22
23 /**
24 * @since 3.6.0
25 */
26 public function __construct(Event $event)
27 {
28 $this->event = $event;
29 }
30
31 /**
32 * @since 3.6.0
33 */
34 public function exports(): array
35 {
36 $tickets = $this->event->eventTickets()->getAll() ?? [];
37
38 return array_merge($this->event->toArray(), [
39 'ticketTypes' => array_map(function (EventTicketType $ticketType) {
40 return EventTicketTypeData::make($ticketType)->toArray();
41 }, $this->event->ticketTypes()->getAll() ?? []),
42 'forms' => array_map(function (DonationForm $form) {
43 return ['id' => $form->id, 'title' => $form->title];
44 }, $this->event->forms()->getAll() ?? []),
45 'tickets' => array_map(new AttachAttendeeDataToTicketData($tickets), $tickets),
46 ]);
47 }
48 }
49