1 | <?php |
||
19 | class UserOrder |
||
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 User |
||
60 | * |
||
61 | * @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", fetch="EAGER") |
||
62 | * @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="SET NULL") |
||
63 | * |
||
64 | * @Serializer\Type("AppBundle\Entity\User") |
||
65 | * @Expose() |
||
66 | */ |
||
67 | protected $user; |
||
68 | |||
69 | /** |
||
70 | * UserOrder constructor. |
||
71 | */ |
||
72 | public function __construct(User $user) |
||
79 | |||
80 | /** |
||
81 | * @return Uuid |
||
82 | */ |
||
83 | public function getId(): Uuid |
||
87 | |||
88 | /** |
||
89 | * @return Ticket[]|ArrayCollection |
||
90 | */ |
||
91 | public function getTickets() |
||
95 | |||
96 | /** |
||
97 | * @param Ticket[]|ArrayCollection $tickets |
||
98 | * |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function setTickets($tickets) |
||
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getStatus(): string |
||
115 | |||
116 | /** |
||
117 | * @param String $status |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function setStatus($status) |
||
127 | |||
128 | /** |
||
129 | * Add Ticket |
||
130 | * |
||
131 | * @param Ticket $ticket |
||
132 | * |
||
133 | * @return $this |
||
134 | */ |
||
135 | public function addTicket(Ticket $ticket) |
||
144 | |||
145 | /** |
||
146 | * @param Ticket $ticket |
||
147 | * |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function removeTicket(Ticket $ticket) |
||
159 | |||
160 | /** |
||
161 | * @return bool |
||
162 | */ |
||
163 | private function isStatusPaid(): bool |
||
167 | |||
168 | /** |
||
169 | * @return array |
||
170 | */ |
||
171 | public static function getStatuses(): array |
||
181 | |||
182 | /** |
||
183 | * @return User |
||
184 | */ |
||
185 | public function getUser(): User |
||
189 | |||
190 | /** |
||
191 | * @param $user |
||
192 | * |
||
193 | * @return UserOrder |
||
194 | */ |
||
195 | public function setUser(User $user) |
||
201 | } |
||
202 |