1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Knp\DoctrineBehaviors\Model as ORMBehaviors; |
7
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* FormRequest. |
12
|
|
|
* |
13
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\FormRequestRepository") |
14
|
|
|
*/ |
15
|
|
|
class FormRequest |
16
|
|
|
{ |
17
|
|
|
use ORMBehaviors\Timestampable\Timestampable; |
18
|
|
|
|
19
|
|
|
const STATUS = ['pending', 'approved', 'rejected']; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var int |
23
|
|
|
* |
24
|
|
|
* @ORM\Column(name="id", type="integer") |
25
|
|
|
* @ORM\Id |
26
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
27
|
|
|
*/ |
28
|
|
|
private $id; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var FormRequestType |
32
|
|
|
* @Assert\Type("object") |
33
|
|
|
* @Assert\Valid |
34
|
|
|
* @ORM\ManyToOne(targetEntity="FormRequestType", inversedBy="requests") |
35
|
|
|
* @Groups({"Detail"}) |
36
|
|
|
*/ |
37
|
|
|
private $type; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
* @Assert\NotBlank() |
42
|
|
|
* @Assert\Type("string") |
43
|
|
|
* @Assert\Length( |
44
|
|
|
* max = 255 |
45
|
|
|
* ) |
46
|
|
|
* @ORM\Column(type="string", length=255) |
47
|
|
|
* @Groups({"Detail"}) |
48
|
|
|
*/ |
49
|
|
|
private $status; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var User |
53
|
|
|
* @Assert\Type("object") |
54
|
|
|
* @Assert\Valid |
55
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="formRequests") |
56
|
|
|
*/ |
57
|
|
|
private $user; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var \DateTime |
61
|
|
|
* @Assert\Date() |
62
|
|
|
* @ORM\Column(type="datetime") |
63
|
|
|
* @Groups({"Detail"}) |
64
|
|
|
*/ |
65
|
|
|
private $date; |
66
|
|
|
|
67
|
|
|
public function __construct() |
68
|
|
|
{ |
69
|
|
|
$this->setStatus("pending"); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get id. |
74
|
|
|
* |
75
|
|
|
* @return int |
76
|
|
|
*/ |
77
|
1 |
|
public function getId() |
78
|
|
|
{ |
79
|
1 |
|
return $this->id; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Set type. |
84
|
|
|
* |
85
|
|
|
* @param FormRequestType $type |
86
|
|
|
* |
87
|
|
|
* @return FormRequest |
88
|
|
|
*/ |
89
|
|
|
public function setType(FormRequestType $type) |
90
|
|
|
{ |
91
|
|
|
$this->type = $type; |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Get type. |
98
|
|
|
* |
99
|
|
|
* @return FormRequestType |
100
|
|
|
*/ |
101
|
1 |
|
public function getType() |
102
|
|
|
{ |
103
|
1 |
|
return $this->type; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Set status. |
108
|
|
|
* |
109
|
|
|
* @param string $status |
110
|
|
|
* |
111
|
|
|
* @return FormRequest |
112
|
|
|
*/ |
113
|
|
|
public function setStatus($status) |
114
|
|
|
{ |
115
|
|
|
if (in_array($status, self::STATUS)) { |
116
|
|
|
$this->status = $status; |
117
|
|
|
} |
118
|
|
|
return $this; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get status. |
123
|
|
|
* |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
1 |
|
public function getStatus() |
127
|
|
|
{ |
128
|
1 |
|
return $this->status; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Set user. |
133
|
|
|
* |
134
|
|
|
* @param User $user |
135
|
|
|
* |
136
|
|
|
* @return FormRequest |
137
|
|
|
*/ |
138
|
|
|
public function setUser(User $user) |
139
|
|
|
{ |
140
|
|
|
$this->user = $user; |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Get user. |
147
|
|
|
* |
148
|
|
|
* @return User |
149
|
|
|
*/ |
150
|
|
|
public function getUser() |
151
|
|
|
{ |
152
|
|
|
return $this->user; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Set date. |
157
|
|
|
* |
158
|
|
|
* @param \DateTime $date |
159
|
|
|
* |
160
|
|
|
* @return FormRequest |
161
|
|
|
*/ |
162
|
|
|
public function setDate($date) |
163
|
|
|
{ |
164
|
|
|
$this->date = $date; |
165
|
|
|
|
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
/** |
169
|
|
|
* Get date. |
170
|
|
|
* |
171
|
|
|
* @return \DateTime |
172
|
|
|
*/ |
173
|
1 |
|
public function getDate() |
174
|
|
|
{ |
175
|
1 |
|
return $this->date; |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
|