PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.14.0
GiveWP – Donation Plugin and Fundraising Platform v4.14.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 / DataTransferObjects / EventTicketTypeData.php
EventTicketTypeData.php
85 lines 1.4 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\DataTransferObjects;
4
5 use Give\EventTickets\Models\EventTicketType;
6
7 final class EventTicketTypeData
8 {
9
10 /**
11 * @since 3.6.0
12 * @var int
13 */
14 public $id;
15
16 /**
17 * @since 3.6.0
18 * @var int
19 */
20 public $eventId;
21
22 /**
23 * @since 3.6.0
24 * @var string
25 */
26 public $title;
27
28 /**
29 * @since 3.6.0
30 * @var string
31 */
32 public $description;
33
34 /**
35 * @since 3.6.0
36 * @var int
37 */
38 public $price;
39
40 /**
41 * @since 3.6.0
42 * @var int
43 */
44 public $capacity;
45
46 /**
47 * @since 3.6.0
48 * @var int
49 */
50 public $salesCount;
51
52 /**
53 * @since 3.6.0
54 * @var int
55 */
56 public $ticketsAvailable;
57
58 /**
59 * @since 3.6.0
60 */
61 public static function make(EventTicketType $ticketType)
62 {
63 $self = new self();
64
65 $self->id = $ticketType->id;
66 $self->eventId = $ticketType->eventId;
67 $self->title = $ticketType->title;
68 $self->description = $ticketType->description;
69 $self->price = $ticketType->price->formatToMinorAmount();
70 $self->capacity = $ticketType->capacity;
71 $self->salesCount = $ticketType->eventTickets()->count();
72 $self->ticketsAvailable = $self->capacity - $self->salesCount;
73
74 return $self;
75 }
76
77 /**
78 * @since 3.6.0
79 */
80 public function toArray(): array
81 {
82 return get_object_vars($this);
83 }
84 }
85