1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Vote. |
9
|
|
|
* |
10
|
|
|
* @ORM\Table(name="votes") |
11
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\VoteRepository") |
12
|
|
|
*/ |
13
|
|
|
class Vote |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var int |
17
|
|
|
* |
18
|
|
|
* @ORM\Column(name="id", type="integer") |
19
|
|
|
* @ORM\Id |
20
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
21
|
|
|
*/ |
22
|
|
|
private $id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var int |
26
|
|
|
* |
27
|
|
|
* @ORM\Column(name="weight", type="integer") |
28
|
|
|
*/ |
29
|
|
|
private $weight; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var \AppBundle\Entity\Poll |
33
|
|
|
* |
34
|
|
|
* @ORM\ManyToOne(targetEntity="Poll", inversedBy="votes") |
35
|
|
|
* @ORM\JoinColumn(name="poll_id", referencedColumnName="id") |
36
|
|
|
*/ |
37
|
|
|
private $poll; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \AppBundle\Entity\User |
41
|
|
|
* |
42
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="votes") |
43
|
|
|
* @ORM\JoinColumn(name="caster_id", referencedColumnName="id") |
44
|
|
|
*/ |
45
|
|
|
private $caster; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var \DateTime |
49
|
|
|
* |
50
|
|
|
* @ORM\Column(name="time", type="datetime") |
51
|
|
|
*/ |
52
|
|
|
private $time; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var \AppBundle\Entity\Choice |
56
|
|
|
* |
57
|
|
|
* @ORM\ManyToOne(targetEntity="Choice", inversedBy="votes") |
58
|
|
|
* @ORM\JoinColumn(name="choice_id", referencedColumnName="id") |
59
|
|
|
*/ |
60
|
|
|
private $choice; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Constructor. |
64
|
|
|
*/ |
65
|
|
|
public function __construct() |
66
|
|
|
{ |
67
|
|
|
$this->time = new \DateTime(); |
68
|
|
|
$this->weight = 1; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get id. |
73
|
|
|
* |
74
|
|
|
* @return int |
75
|
|
|
*/ |
76
|
|
|
public function getId(): int |
77
|
|
|
{ |
78
|
|
|
return $this->id; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Get time. |
83
|
|
|
* |
84
|
|
|
* @return \DateTime |
85
|
|
|
*/ |
86
|
|
|
public function getTime(): DateTime |
87
|
|
|
{ |
88
|
|
|
return $this->time; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Set time. |
93
|
|
|
* |
94
|
|
|
* @param \DateTime $time |
95
|
|
|
* |
96
|
|
|
* @return Vote |
97
|
|
|
*/ |
98
|
|
|
public function setTime(\DateTime $time) |
99
|
|
|
{ |
100
|
|
|
$this->time = $time; |
101
|
|
|
|
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Get poll. |
107
|
|
|
* |
108
|
|
|
* @return \AppBundle\Entity\Poll |
109
|
|
|
*/ |
110
|
|
|
public function getPoll(): \AppBundle\Entity\Poll |
111
|
|
|
{ |
112
|
|
|
return $this->poll; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Set poll. |
117
|
|
|
* |
118
|
|
|
* @param \AppBundle\Entity\Poll $poll |
119
|
|
|
* |
120
|
|
|
* @return Vote |
121
|
|
|
*/ |
122
|
|
|
public function setPoll(\AppBundle\Entity\Poll $poll = null) |
123
|
|
|
{ |
124
|
|
|
$this->poll = $poll; |
125
|
|
|
|
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get caster. |
131
|
|
|
* |
132
|
|
|
* @return \AppBundle\Entity\User |
133
|
|
|
*/ |
134
|
|
|
public function getCaster(): \AppBundle\Entity\User |
135
|
|
|
{ |
136
|
|
|
return $this->caster; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Set caster. |
141
|
|
|
* |
142
|
|
|
* @param \AppBundle\Entity\User $caster |
143
|
|
|
* |
144
|
|
|
* @return Vote |
145
|
|
|
*/ |
146
|
|
|
public function setCaster(\AppBundle\Entity\User $caster = null) |
147
|
|
|
{ |
148
|
|
|
$this->caster = $caster; |
149
|
|
|
|
150
|
|
|
return $this; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Get choice. |
155
|
|
|
* |
156
|
|
|
* @return \AppBundle\Entity\Choice |
157
|
|
|
*/ |
158
|
|
|
public function getChoice(): \AppBundle\Entity\Choice |
159
|
|
|
{ |
160
|
|
|
return $this->choice; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Set choice. |
165
|
|
|
* |
166
|
|
|
* @param \AppBundle\Entity\Choice $choice |
167
|
|
|
* |
168
|
|
|
* @return Vote |
169
|
|
|
*/ |
170
|
|
|
public function setChoice(\AppBundle\Entity\Choice $choice = null) |
171
|
|
|
{ |
172
|
|
|
$this->choice = $choice; |
173
|
|
|
|
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get weight. |
179
|
|
|
* |
180
|
|
|
* @return int |
181
|
|
|
*/ |
182
|
|
|
public function getWeight(): int |
183
|
|
|
{ |
184
|
|
|
return $this->weight; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Set weight. |
189
|
|
|
* |
190
|
|
|
* @param int $weight |
191
|
|
|
* |
192
|
|
|
* @return Vote |
193
|
|
|
*/ |
194
|
|
|
public function setWeight(int $weight) |
195
|
|
|
{ |
196
|
|
|
$this->weight = $weight; |
197
|
|
|
|
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|