src/Aqarmap/Bundle/MainBundle/Entity/Feedback.php line 26

  1. <?php
  2. namespace Aqarmap\Bundle\MainBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. use JMS\Serializer\Annotation as Serializer;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClass: \Aqarmap\Bundle\MainBundle\Repository\FeedbackRepository::class)]
  8. #[ORM\HasLifecycleCallbacks]
  9. #[ORM\Table(name: 'feedback')]
  10. #[ORM\Index(columns: ['source'])]
  11. #[Gedmo\SoftDeleteable(fieldName: 'deleted_at', timeAware: false)]
  12. #[Serializer\ExclusionPolicy('all')]
  13. class Feedback
  14. {
  15. /**
  16. * @var int
  17. */
  18. #[ORM\Column(name: 'id', type: 'integer')]
  19. #[ORM\Id]
  20. #[ORM\GeneratedValue(strategy: 'AUTO')]
  21. #[Serializer\Expose]
  22. private $id;
  23. /**
  24. * @var string
  25. */
  26. #[ORM\Column(name: 'note', type: 'text', nullable: true)]
  27. private $note;
  28. /**
  29. * @var string
  30. */
  31. #[Assert\NotBlank]
  32. #[ORM\Column(name: 'author', type: 'string', length: 100)]
  33. #[Serializer\Expose]
  34. private $author;
  35. /**
  36. * @var string
  37. */
  38. #[Assert\NotBlank]
  39. #[ORM\Column(name: 'email', type: 'string', length: 255)]
  40. #[Serializer\Expose]
  41. private $email;
  42. /**
  43. * @var string
  44. */
  45. #[Assert\NotBlank]
  46. #[ORM\Column(name: 'message', type: 'text')]
  47. #[Serializer\Expose]
  48. private $message;
  49. /**
  50. * @var string
  51. */
  52. #[ORM\Column(name: 'ip', type: 'string', length: 255)]
  53. #[Serializer\Expose]
  54. private $ip;
  55. /**
  56. * @var array
  57. */
  58. #[ORM\Column(name: 'collected_data', type: 'array')]
  59. private $collectedData;
  60. /**
  61. * @var \DateTime
  62. */
  63. #[ORM\Column(name: 'created_at', type: 'datetime')]
  64. private $createdAt;
  65. #[ORM\Column(name: 'deleted_at', type: 'datetime', nullable: true)]
  66. private $deleted_at;
  67. /**
  68. * @var string|null
  69. */
  70. #[ORM\Column(name: 'source', type: 'string', nullable: true)]
  71. private $source;
  72. /**
  73. * Get id.
  74. *
  75. * @return int
  76. */
  77. public function getId()
  78. {
  79. return $this->id;
  80. }
  81. /**
  82. * Set author.
  83. *
  84. * @param string $author
  85. *
  86. * @return Feedback
  87. */
  88. public function setAuthor($author)
  89. {
  90. $this->author = $author;
  91. return $this;
  92. }
  93. /**
  94. * Get author.
  95. *
  96. * @return string
  97. */
  98. public function getAuthor()
  99. {
  100. return $this->author;
  101. }
  102. /**
  103. * Set email.
  104. *
  105. * @param string $email
  106. *
  107. * @return Feedback
  108. */
  109. public function setEmail($email)
  110. {
  111. $this->email = $email;
  112. return $this;
  113. }
  114. /**
  115. * Get email.
  116. *
  117. * @return string
  118. */
  119. public function getEmail()
  120. {
  121. return $this->email;
  122. }
  123. /**
  124. * Set message.
  125. *
  126. * @param string $message
  127. *
  128. * @return Feedback
  129. */
  130. public function setMessage($message)
  131. {
  132. $this->message = $message;
  133. return $this;
  134. }
  135. /**
  136. * Get message.
  137. *
  138. * @return string
  139. */
  140. public function getMessage()
  141. {
  142. return $this->message;
  143. }
  144. /**
  145. * Set ip.
  146. *
  147. * @param string $ip
  148. *
  149. * @return Feedback
  150. */
  151. public function setIp($ip)
  152. {
  153. $this->ip = $ip;
  154. return $this;
  155. }
  156. /**
  157. * Get ip.
  158. *
  159. * @return string
  160. */
  161. public function getIp()
  162. {
  163. return $this->ip;
  164. }
  165. /**
  166. * Set collectedData.
  167. *
  168. * @param array $collectedData
  169. *
  170. * @return Feedback
  171. */
  172. public function setCollectedData($collectedData)
  173. {
  174. $this->collectedData = $collectedData;
  175. return $this;
  176. }
  177. /**
  178. * Get collectedData.
  179. *
  180. * @return array
  181. */
  182. public function getCollectedData()
  183. {
  184. return $this->collectedData;
  185. }
  186. /**
  187. * Set createdAt.
  188. *
  189. * @param \DateTime $createdAt
  190. *
  191. * @return Feedback
  192. */
  193. public function setCreatedAt($createdAt)
  194. {
  195. $this->createdAt = $createdAt;
  196. return $this;
  197. }
  198. /**
  199. * Get createdAt.
  200. *
  201. * @return \DateTime
  202. */
  203. public function getCreatedAt()
  204. {
  205. return $this->createdAt;
  206. }
  207. #[ORM\PrePersist]
  208. public function onPrePersist(): void
  209. {
  210. $this->setCreatedAt(new \DateTime());
  211. }
  212. /**
  213. * Set note.
  214. *
  215. * @param string $note
  216. *
  217. * @return Feedback
  218. */
  219. public function setNote($note)
  220. {
  221. $this->note = $note;
  222. return $this;
  223. }
  224. /**
  225. * Get note.
  226. *
  227. * @return string
  228. */
  229. public function getNote()
  230. {
  231. return $this->note;
  232. }
  233. /**
  234. * Set deletedAt.
  235. *
  236. * @return Feedback
  237. */
  238. public function setDeletedAt($deleted_at)
  239. {
  240. $this->deleted_at = $deleted_at;
  241. return $this;
  242. }
  243. /**
  244. * Get deletedAt.
  245. *
  246. * @return \DateTime
  247. */
  248. public function getDeletedAt()
  249. {
  250. return $this->deleted_at;
  251. }
  252. public function getSource(): ?string
  253. {
  254. return $this->source;
  255. }
  256. public function setSource(?string $source): self
  257. {
  258. $this->source = $source;
  259. return $this;
  260. }
  261. public function toArray(): array
  262. {
  263. return [
  264. 'author' => $this->getAuthor(),
  265. 'email' => $this->getEmail(),
  266. 'message' => $this->getMessage(),
  267. ];
  268. }
  269. }