1 | <?php |
||
20 | class UserOrder |
||
21 | { |
||
22 | use TimestampableTrait; |
||
23 | |||
24 | const STATUS_OPENED = 'opened'; |
||
25 | const STATUS_CLOSED = 'closed'; |
||
26 | const STATUS_PENDING = 'pending'; |
||
27 | const STATUS_PAID = 'paid'; |
||
28 | const STATUS_REJECTED = 'rejected'; |
||
29 | |||
30 | /** |
||
31 | * @var Uuid |
||
32 | * |
||
33 | * @ORM\Column(name="id", type="uuid_binary") |
||
34 | * @ORM\Id |
||
35 | * @ORM\GeneratedValue(strategy="UUID") |
||
36 | */ |
||
37 | private $id; |
||
38 | |||
39 | /** |
||
40 | * @var ArrayCollection|Ticket[] |
||
41 | * |
||
42 | * @ORM\OneToMany( |
||
43 | * targetEntity="AppBundle\Entity\Ticket", |
||
44 | * mappedBy="object", |
||
45 | * cascade={"persist", "remove"} |
||
46 | * ) |
||
47 | */ |
||
48 | protected $tickets; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | * @Assert\Choice(callback="getStatuses") |
||
53 | * @ORM\Column(name="status", type="string", length=15) |
||
54 | * @Serializer\Type("string") |
||
55 | * @Expose() |
||
56 | */ |
||
57 | protected $status; |
||
58 | |||
59 | /** |
||
60 | * @var User |
||
61 | * |
||
62 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="orders") |
||
63 | * @Type("AppBundle\Entity\User") |
||
64 | */ |
||
65 | private $user; |
||
66 | /** |
||
67 | * UserOrder constructor. |
||
68 | */ |
||
69 | public function __construct() |
||
75 | |||
76 | /** |
||
77 | * @return Uuid |
||
78 | */ |
||
79 | public function getId(): Uuid |
||
83 | /** |
||
84 | * Get user. |
||
85 | * |
||
86 | * @return \AppBundle\Entity\User |
||
87 | */ |
||
88 | public function getUser() |
||
92 | /** |
||
93 | * @return Ticket[]|ArrayCollection |
||
94 | */ |
||
95 | public function getTickets() |
||
99 | |||
100 | /** |
||
101 | * @param Ticket[]|ArrayCollection $tickets |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setTickets($tickets) |
||
111 | |||
112 | /** |
||
113 | * @return string |
||
114 | */ |
||
115 | public function getStatus(): string |
||
119 | |||
120 | /** |
||
121 | * @param String $status |
||
122 | * |
||
123 | * @return $this |
||
124 | */ |
||
125 | public function setStatus($status) |
||
131 | |||
132 | /** |
||
133 | * Add Ticket |
||
134 | * |
||
135 | * @param Ticket $ticket |
||
136 | * |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function addTicket(Ticket $ticket) |
||
148 | |||
149 | /** |
||
150 | * @param Ticket $ticket |
||
151 | * |
||
152 | * @return $this |
||
153 | */ |
||
154 | public function removeTicket(Ticket $ticket) |
||
163 | |||
164 | /** |
||
165 | * @return bool |
||
166 | */ |
||
167 | private function isStatusPaid(): bool |
||
171 | |||
172 | /** |
||
173 | * @return array |
||
174 | */ |
||
175 | public static function getStatuses(): array |
||
185 | } |
||
186 |