1 | <?php |
||
19 | class CustomerOrder |
||
20 | { |
||
21 | use TimestampableTrait; |
||
22 | |||
23 | const STATUS_OPENED = 'opened'; |
||
24 | const STATUS_CLOSED = 'closed'; |
||
25 | const STATUS_PENDING = 'pending'; |
||
26 | const STATUS_PAID = 'paid'; |
||
27 | const STATUS_REJECTED = 'rejected'; |
||
28 | |||
29 | /** |
||
30 | * @var Uuid |
||
31 | * |
||
32 | * @ORM\Column(name="id", type="uuid_binary") |
||
33 | * @ORM\Id |
||
34 | * @ORM\GeneratedValue(strategy="UUID") |
||
35 | */ |
||
36 | private $id; |
||
37 | |||
38 | /** |
||
39 | * @var ArrayCollection|Ticket[] |
||
40 | * |
||
41 | * @ORM\OneToMany( |
||
42 | * targetEntity="AppBundle\Entity\Ticket", |
||
43 | * mappedBy="object", |
||
44 | * cascade={"persist", "remove"} |
||
45 | * ) |
||
46 | */ |
||
47 | protected $tickets; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | * @Assert\Choice(callback="getStatuses") |
||
52 | * @ORM\Column(name="status", type="string", length=15) |
||
53 | * @Serializer\Type("string") |
||
54 | * @Expose() |
||
55 | */ |
||
56 | protected $status; |
||
57 | |||
58 | /** |
||
59 | * @var Customer |
||
60 | * |
||
61 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Customer") |
||
62 | * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="SET NULL") |
||
63 | */ |
||
64 | protected $customer; |
||
65 | |||
66 | /** |
||
67 | * CustomerOrder constructor. |
||
68 | */ |
||
69 | public function __construct(Customer $customer) |
||
76 | |||
77 | /** |
||
78 | * @return Uuid |
||
79 | */ |
||
80 | public function getId(): Uuid |
||
84 | |||
85 | /** |
||
86 | * @return Ticket[]|ArrayCollection |
||
87 | */ |
||
88 | public function getTickets() |
||
92 | |||
93 | /** |
||
94 | * @param Ticket[]|ArrayCollection $tickets |
||
95 | * |
||
96 | * @return CustomerOrder |
||
97 | */ |
||
98 | public function setTickets($tickets) |
||
104 | |||
105 | /** |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getStatus(): string |
||
112 | |||
113 | /** |
||
114 | * @param String $status |
||
115 | * |
||
116 | * @return CustomerOrder |
||
117 | */ |
||
118 | public function setStatus($status) |
||
124 | |||
125 | /** |
||
126 | * @return Customer |
||
127 | */ |
||
128 | public function getCustomer() |
||
132 | |||
133 | /** |
||
134 | * @param $customer |
||
135 | * |
||
136 | * @return CustomerOrder |
||
137 | */ |
||
138 | public function setCustomer($customer) |
||
144 | |||
145 | /** |
||
146 | * Add Ticket |
||
147 | * |
||
148 | * @param Ticket $ticket |
||
149 | * |
||
150 | * @return CustomerOrder |
||
151 | */ |
||
152 | public function addTicket(Ticket $ticket) |
||
161 | |||
162 | /** |
||
163 | * @param Ticket $ticket |
||
164 | * |
||
165 | * @return CustomerOrder |
||
166 | */ |
||
167 | public function removeTicket(Ticket $ticket) |
||
176 | |||
177 | /** |
||
178 | * @return bool |
||
179 | */ |
||
180 | private function isStatusPaid(): bool |
||
184 | /** |
||
185 | * @return array |
||
186 | */ |
||
187 | public static function getStatuses(): array |
||
197 | } |
||
198 |