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
|
|
|
* Set time. |
83
|
|
|
* |
84
|
|
|
* @param \DateTime $time |
85
|
|
|
* |
86
|
|
|
* @return Vote |
87
|
|
|
*/ |
88
|
|
|
public function setTime(\DateTime $time) |
89
|
|
|
{ |
90
|
|
|
$this->time = $time; |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get time. |
97
|
|
|
* |
98
|
|
|
* @return \DateTime |
99
|
|
|
*/ |
100
|
|
|
public function getTime(): DateTime |
101
|
|
|
{ |
102
|
|
|
return $this->time; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Set poll. |
107
|
|
|
* |
108
|
|
|
* @param \AppBundle\Entity\Poll $poll |
109
|
|
|
* |
110
|
|
|
* @return Vote |
111
|
|
|
*/ |
112
|
|
|
public function setPoll(\AppBundle\Entity\Poll $poll = null) |
113
|
|
|
{ |
114
|
|
|
$this->poll = $poll; |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Get poll. |
121
|
|
|
* |
122
|
|
|
* @return \AppBundle\Entity\Poll |
123
|
|
|
*/ |
124
|
|
|
public function getPoll(): AppBundle\Entity\Poll |
125
|
|
|
{ |
126
|
|
|
return $this->poll; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Set caster. |
131
|
|
|
* |
132
|
|
|
* @param \AppBundle\Entity\User $caster |
133
|
|
|
* |
134
|
|
|
* @return Vote |
135
|
|
|
*/ |
136
|
|
|
public function setCaster(\AppBundle\Entity\User $caster = null) |
137
|
|
|
{ |
138
|
|
|
$this->caster = $caster; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Get caster. |
145
|
|
|
* |
146
|
|
|
* @return \AppBundle\Entity\User |
147
|
|
|
*/ |
148
|
|
|
public function getCaster(): AppBundle\Entity\User |
149
|
|
|
{ |
150
|
|
|
return $this->caster; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Set choice. |
155
|
|
|
* |
156
|
|
|
* @param \AppBundle\Entity\Choice $choice |
157
|
|
|
* |
158
|
|
|
* @return Vote |
159
|
|
|
*/ |
160
|
|
|
public function setChoice(\AppBundle\Entity\Choice $choice = null) |
161
|
|
|
{ |
162
|
|
|
$this->choice = $choice; |
163
|
|
|
|
164
|
|
|
return $this; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Get choice. |
169
|
|
|
* |
170
|
|
|
* @return \AppBundle\Entity\Choice |
171
|
|
|
*/ |
172
|
|
|
public function getChoice(): AppBundle\Entity\Choice |
173
|
|
|
{ |
174
|
|
|
return $this->choice; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Set weight |
179
|
|
|
* |
180
|
|
|
* @param integer $weight |
181
|
|
|
* |
182
|
|
|
* @return Vote |
183
|
|
|
*/ |
184
|
|
|
public function setWeight($weight) |
185
|
|
|
{ |
186
|
|
|
$this->weight = $weight; |
187
|
|
|
|
188
|
|
|
return $this; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Get weight |
193
|
|
|
* |
194
|
|
|
* @return integer |
195
|
|
|
*/ |
196
|
|
|
public function getWeight() |
197
|
|
|
{ |
198
|
|
|
return $this->weight; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|