src/Entity/UserComments.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use DateTimeInterface;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use function date_format;
  7. /**
  8. * UserComments
  9. *
  10. * @ORM\Table(
  11. * name="user_comments",
  12. * indexes={
  13. * @ORM\Index(name="comment", columns={"comment"}),
  14. * @ORM\Index(name="ip_address", columns={"ip_address"}),
  15. * @ORM\Index(name="user_name", columns={"user_name","ip_address"})
  16. * }
  17. * )
  18. * @ORM\Entity
  19. */
  20. class UserComments
  21. {
  22. /**
  23. * @var int
  24. *
  25. * @ORM\Column(type="integer", name="id", options={"comment":"Id of the comment."})
  26. * @ORM\Id
  27. * @ORM\GeneratedValue(strategy="IDENTITY")
  28. */
  29. private int $id;
  30. /**
  31. * @var int
  32. *
  33. * @ORM\Column(type="integer", name="hymn_id", options={"comment":"Id of the hymn that the comment is about."})
  34. */
  35. private int $hymnId;
  36. /**
  37. * @var DateTime
  38. *
  39. * @ORM\Column(
  40. * type="datetime",
  41. * nullable=false,
  42. * name="comment_date",
  43. * options={"comment":"The date and time the comment was made."}
  44. * )
  45. */
  46. private DateTime $commentDate;
  47. /**
  48. * @var int
  49. *
  50. * @ORM\Column(type="integer", name="user_id", options={"comment":"Id of the user that made the comment."})
  51. */
  52. private int $userId;
  53. /**
  54. * @var string|null
  55. *
  56. * @ORM\Column(
  57. * type="string",
  58. * length=50,
  59. * nullable=true,
  60. * name="user_name",
  61. * options={"comment":"User name of person making the comment."}
  62. * )
  63. */
  64. private ?string $userName;
  65. /**
  66. * @var string
  67. *
  68. * @ORM\Column(
  69. * type="string",
  70. * length=16,
  71. * nullable=false,
  72. * name="ip_address",
  73. * options={"comment":"The IP that the user made the comment from."}
  74. * )
  75. */
  76. private string $ipAddress;
  77. /**
  78. * @var string
  79. *
  80. * @ORM\Column(
  81. * type="text",
  82. * length=65535,
  83. * nullable=false,
  84. * name="comment",
  85. * options={"comment":"The comment for the hymn."}
  86. * )
  87. */
  88. private string $comment;
  89. /**
  90. * @var string
  91. *
  92. * @ORM\Column(type="string", length=250, nullable=false, name="Referring_URL")
  93. */
  94. private string $referringUrl;
  95. /**
  96. * @var string
  97. *
  98. * @ORM\Column(type="string", length=500, nullable=false, name="HTTP_Agent")
  99. */
  100. private string $httpAgent;
  101. /**
  102. * @var string
  103. *
  104. * @ORM\Column(type="string", length=250, nullable=false, name="email", options={"comment":"User's email address"})
  105. */
  106. private string $email;
  107. /**
  108. * @var string
  109. */
  110. private string $strCommentDate;
  111. /**
  112. * @return string
  113. */
  114. public function getStrCommentDate(): string
  115. {
  116. return $this->strCommentDate;
  117. }
  118. /**
  119. * @param DateTimeInterface $cDate
  120. */
  121. public function setStrCommentDate(DateTimeInterface $cDate): void
  122. {
  123. $this->strCommentDate = date_format($cDate, 'M d, Y');
  124. }
  125. /**
  126. * @return int|null
  127. */
  128. public function getHymnId(): ?int
  129. {
  130. return $this->hymnId;
  131. }
  132. /**
  133. * @return int
  134. */
  135. public function getId(): int
  136. {
  137. return $this->id;
  138. }
  139. /**
  140. * @param int $hymnId
  141. */
  142. public function setHymnId(int $hymnId): void
  143. {
  144. $this->hymnId = $hymnId;
  145. }
  146. /**
  147. * @param DateTime $commentDate
  148. */
  149. public function setCommentDate(DateTime $commentDate): void
  150. {
  151. $this->commentDate = $commentDate;
  152. }
  153. /**
  154. * @return DateTimeInterface|null
  155. */
  156. public function getCommentDate(): ?DateTimeInterface
  157. {
  158. return $this->commentDate;
  159. }
  160. /**
  161. * @return string|null
  162. */
  163. public function getUserName(): ?string
  164. {
  165. return $this->userName;
  166. }
  167. /**
  168. * @param string|null $userName
  169. *
  170. * @return $this
  171. */
  172. public function setUserName(?string $userName): self
  173. {
  174. $this->userName = $userName;
  175. return $this;
  176. }
  177. /**
  178. * @return string|null
  179. */
  180. public function getIpAddress(): ?string
  181. {
  182. return $this->ipAddress;
  183. }
  184. /**
  185. * @param string $ipAddress
  186. *
  187. * @return $this
  188. */
  189. public function setIpAddress(string $ipAddress): self
  190. {
  191. $this->ipAddress = $ipAddress;
  192. return $this;
  193. }
  194. /**
  195. * @return string|null
  196. */
  197. public function getComment(): ?string
  198. {
  199. return $this->comment;
  200. }
  201. /**
  202. * @param string $comment
  203. *
  204. * @return $this
  205. */
  206. public function setComment(string $comment): self
  207. {
  208. $this->comment = $comment;
  209. return $this;
  210. }
  211. /**
  212. * @return string|null
  213. */
  214. public function getReferringUrl(): ?string
  215. {
  216. return $this->referringUrl;
  217. }
  218. /**
  219. * @param string $referringUrl
  220. *
  221. * @return $this
  222. */
  223. public function setReferringUrl(string $referringUrl): self
  224. {
  225. $this->referringUrl = $referringUrl;
  226. return $this;
  227. }
  228. /**
  229. * @return string|null
  230. */
  231. public function getHttpAgent(): ?string
  232. {
  233. return $this->httpAgent;
  234. }
  235. /**
  236. * @param string $httpAgent
  237. *
  238. * @return $this
  239. */
  240. public function setHttpAgent(string $httpAgent): self
  241. {
  242. $this->httpAgent = $httpAgent;
  243. return $this;
  244. }
  245. /**
  246. * @return string|null
  247. */
  248. public function getEmail(): ?string
  249. {
  250. return $this->email;
  251. }
  252. /**
  253. * @param string $email
  254. *
  255. * @return $this
  256. */
  257. public function setEmail(string $email): self
  258. {
  259. $this->email = $email;
  260. return $this;
  261. }
  262. /**
  263. * @return string
  264. */
  265. public function __toString()
  266. {
  267. return (string) $this->getUserName();
  268. }
  269. /**
  270. * @return int
  271. */
  272. public function getUserId(): int
  273. {
  274. return $this->userId;
  275. }
  276. /**
  277. * @param int $userId
  278. * @return UserComments
  279. */
  280. public function setUserId( int $userId ): self
  281. {
  282. $this->userId = $userId;
  283. return $this;
  284. }
  285. }