1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use AppBundle\Cart\Cart; |
6
|
|
|
use AppBundle\Util\Uuid; |
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
9
|
|
|
use Doctrine\ORM\Mapping\Id; |
10
|
|
|
use Doctrine\ORM\Mapping\Table; |
11
|
|
|
use Symfony\Component\Validator\Constraints\Email; |
12
|
|
|
use Symfony\Component\Validator\Constraints\Length; |
13
|
|
|
use Symfony\Component\Validator\Constraints\NotBlank; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @Entity(repositoryClass="OrderRepository") |
17
|
|
|
* @Table(name="`order`") |
18
|
|
|
*/ |
19
|
|
|
class Order |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @Id |
23
|
|
|
* @Column(type="string", length=40) |
24
|
|
|
*/ |
25
|
|
|
private $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @Column(type="json_array", name="`order`") |
29
|
|
|
*/ |
30
|
|
|
private $order; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @Column(type="string", length=128) |
34
|
|
|
* |
35
|
|
|
* @NotBlank |
36
|
|
|
* @Length(max=128) |
37
|
|
|
*/ |
38
|
|
|
private $fullname; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @Column(type="datetime") |
42
|
|
|
*/ |
43
|
|
|
private $createdAt; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @Column(type="string", length=128) |
47
|
|
|
* |
48
|
|
|
* @NotBlank |
49
|
|
|
* @Length(max=128) |
50
|
|
|
*/ |
51
|
|
|
private $phone; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @Column(type="string", length=128) |
55
|
|
|
* |
56
|
|
|
* @NotBlank |
57
|
|
|
* @Email |
58
|
|
|
* @Length(max=128) |
59
|
|
|
*/ |
60
|
|
|
private $email; |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @Column(type="string", length=128) |
65
|
|
|
* |
66
|
|
|
* @NotBlank |
67
|
|
|
* @Length(max=128) |
68
|
|
|
*/ |
69
|
|
|
private $date; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @Column(type="text", nullable=true) |
73
|
|
|
*/ |
74
|
|
|
private $observations; |
75
|
|
|
|
76
|
|
|
public function __construct() |
77
|
|
|
{ |
78
|
|
|
$this->id = Uuid::generateV4(); |
79
|
|
|
$this->createdAt = new \DateTime(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getId() |
83
|
|
|
{ |
84
|
|
|
return $this->id; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getCreatedAt() |
88
|
|
|
{ |
89
|
|
|
return $this->createdAt; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function loadFromCart(Cart $cart) |
93
|
|
|
{ |
94
|
|
|
$this->order = $cart->toArray(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getOrder() |
98
|
|
|
{ |
99
|
|
|
return $this->order; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setOrder(array $order) |
103
|
|
|
{ |
104
|
|
|
$this->order = $order; |
105
|
|
|
|
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getFullname() |
110
|
|
|
{ |
111
|
|
|
return $this->fullname; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function setFullname($fullname) |
115
|
|
|
{ |
116
|
|
|
$this->fullname = $fullname; |
117
|
|
|
|
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function getPhone() |
122
|
|
|
{ |
123
|
|
|
return $this->phone; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function setPhone($phone) |
127
|
|
|
{ |
128
|
|
|
$this->phone = $phone; |
129
|
|
|
|
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getEmail() |
134
|
|
|
{ |
135
|
|
|
return $this->email; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function setEmail($email) |
139
|
|
|
{ |
140
|
|
|
$this->email = $email; |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function getDate() |
146
|
|
|
{ |
147
|
|
|
return $this->date; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function setDate($date) |
151
|
|
|
{ |
152
|
|
|
$this->date = $date; |
153
|
|
|
|
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function getObservations() |
158
|
|
|
{ |
159
|
|
|
return $this->observations; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function setObservations($observations) |
163
|
|
|
{ |
164
|
|
|
$this->observations = $observations; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
} |
170
|
|
|
|