src/Entity/Tema.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity
  9. */
  10. class Tema extends \App\Entity\BaseEntity
  11. {
  12. /**
  13. * @ORM\Id
  14. * @ORM\Column(type="integer")
  15. * @ORM\GeneratedValue(strategy="AUTO")
  16. */
  17. private $id;
  18. /**
  19. * @ORM\Column(type="string", nullable=true)
  20. */
  21. private $titulo;
  22. /**
  23. * @ORM\Column(type="datetime", nullable=true)
  24. */
  25. private $createdAt;
  26. /**
  27. * @ORM\Column(type="datetime", nullable=true)
  28. */
  29. private $updatedAt;
  30. /**
  31. * @ORM\Column(type="integer", nullable=true)
  32. */
  33. private $numeroRespuestas;
  34. /**
  35. * @ORM\Column(type="integer", nullable=true)
  36. */
  37. private $numeroVisitas;
  38. /**
  39. * @ORM\Column(type="string", nullable=true)
  40. */
  41. private $estado;
  42. /**
  43. * @ORM\Column(type="text", nullable=true)
  44. */
  45. private $descripcion;
  46. /**
  47. * @ORM\Column(
  48. * type="json",
  49. * nullable=true,
  50. * options={"comment":"Indica para que roles está disponible el tema, null === public"}
  51. * )
  52. */
  53. private $available;
  54. /**
  55. * @ORM\Column(type="boolean", nullable=true, options={"default":false})
  56. */
  57. private $fijado;
  58. /**
  59. * @ORM\OneToMany(targetEntity=\App\Entity\MensajeForo::class, mappedBy="tema")
  60. */
  61. private $mensajeForos;
  62. /**
  63. * @ORM\ManyToOne(targetEntity=\App\Entity\PropietarioContenido::class, inversedBy="temas")
  64. * @ORM\JoinColumn(name="propietario_contenido_id", referencedColumnName="id")
  65. */
  66. private $propietarioContenido;
  67. /**
  68. * @ORM\ManyToOne(targetEntity=\App\Entity\CategoriaForo::class, inversedBy="temas")
  69. * @ORM\JoinColumn(name="categoria_foro_id", referencedColumnName="id")
  70. */
  71. private $categoriaForo;
  72. /**
  73. * No es un campo de Doctrine. Se usará para almacenar temporalmente la fecha del último mensaje.
  74. */
  75. private $lastMessageDate = null;
  76. /**
  77. * No es un campo de Doctrine. Se usará para almacenar temporalmente si el tema tiene mensajes no leídos.
  78. */
  79. private $hasUnread = false;
  80. /**
  81. * No es un campo de Doctrine. Se usará para almacenar temporalmente si el tema es completamente nuevo (nunca visitado).
  82. */
  83. private $isNew = false;
  84. public function __construct()
  85. {
  86. $this->mensajeForos = new ArrayCollection();
  87. }
  88. public function __toString(): string
  89. {
  90. return $this->getTitulo()?? '--';
  91. }
  92. public function getId(): ?int
  93. {
  94. return $this->id;
  95. }
  96. public function setId($id)
  97. {
  98. $this->id = $id;
  99. return $this;
  100. }
  101. public function getTitulo(): ?string
  102. {
  103. return $this->titulo;
  104. }
  105. public function setTitulo(?string $titulo): static
  106. {
  107. $this->titulo = $titulo;
  108. return $this;
  109. }
  110. public function getCreatedAt(): ?\DateTimeInterface
  111. {
  112. return $this->createdAt;
  113. }
  114. public function setCreatedAt(?\DateTimeInterface $createdAt): static
  115. {
  116. $this->createdAt = $createdAt;
  117. return $this;
  118. }
  119. public function getUpdatedAt(): ?\DateTimeInterface
  120. {
  121. return $this->updatedAt;
  122. }
  123. public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  124. {
  125. $this->updatedAt = $updatedAt;
  126. return $this;
  127. }
  128. public function getNumeroRespuestas(): ?int
  129. {
  130. return $this->mensajeForos->count();
  131. }
  132. public function setNumeroRespuestas(?int $numeroRespuestas): static
  133. {
  134. $this->numeroRespuestas = $numeroRespuestas;
  135. return $this;
  136. }
  137. public function getNumeroVisitas(): ?int
  138. {
  139. return $this->numeroVisitas;
  140. }
  141. public function setNumeroVisitas(?int $numeroVisitas): static
  142. {
  143. $this->numeroVisitas = $numeroVisitas;
  144. return $this;
  145. }
  146. public function getEstado(): ?string
  147. {
  148. return $this->estado;
  149. }
  150. public function setEstado(?string $estado): static
  151. {
  152. $this->estado = $estado;
  153. return $this;
  154. }
  155. public function getDescripcion(): ?string
  156. {
  157. return $this->descripcion;
  158. }
  159. public function setDescripcion(?string $descripcion): static
  160. {
  161. $this->descripcion = $descripcion;
  162. return $this;
  163. }
  164. /**
  165. * @return Collection<int, MensajeForo>
  166. */
  167. public function getMensajeForos(): Collection
  168. {
  169. return $this->mensajeForos;
  170. }
  171. public function addMensajeForo(MensajeForo $mensajeForo): static
  172. {
  173. if (!$this->mensajeForos->contains($mensajeForo)) {
  174. $this->mensajeForos->add($mensajeForo);
  175. $mensajeForo->setTema($this);
  176. }
  177. return $this;
  178. }
  179. public function removeMensajeForo(MensajeForo $mensajeForo): static
  180. {
  181. if ($this->mensajeForos->removeElement($mensajeForo)) {
  182. // set the owning side to null (unless already changed)
  183. if ($mensajeForo->getTema() === $this) {
  184. $mensajeForo->setTema(null);
  185. }
  186. }
  187. return $this;
  188. }
  189. public function getPropietarioContenido(): ?PropietarioContenido
  190. {
  191. return $this->propietarioContenido;
  192. }
  193. public function setPropietarioContenido(?PropietarioContenido $propietarioContenido): static
  194. {
  195. $this->propietarioContenido = $propietarioContenido;
  196. return $this;
  197. }
  198. public function getAvailable(): ?array
  199. {
  200. return $this->available;
  201. }
  202. public function setAvailable(?array $available): static
  203. {
  204. $this->available = $available;
  205. return $this;
  206. }
  207. public function getLastMessageDate(): ?\DateTimeInterface
  208. {
  209. return $this->lastMessageDate;
  210. }
  211. public function setLastMessageDate(?\DateTimeInterface $lastMessageDate): static
  212. {
  213. $this->lastMessageDate = $lastMessageDate;
  214. return $this;
  215. }
  216. public function getHasUnread(): bool
  217. {
  218. return $this->hasUnread;
  219. }
  220. public function setHasUnread(bool $hasUnread): static
  221. {
  222. $this->hasUnread = $hasUnread;
  223. return $this;
  224. }
  225. public function getIsNew(): bool
  226. {
  227. return $this->isNew;
  228. }
  229. public function setIsNew(bool $isNew): static
  230. {
  231. $this->isNew = $isNew;
  232. return $this;
  233. }
  234. public function getCategoriaForo(): ?CategoriaForo
  235. {
  236. return $this->categoriaForo;
  237. }
  238. public function setCategoriaForo(?CategoriaForo $categoriaForo): static
  239. {
  240. $this->categoriaForo = $categoriaForo;
  241. return $this;
  242. }
  243. public function getFijado(): ?bool
  244. {
  245. return $this->fijado;
  246. }
  247. public function setFijado(?bool $fijado): static
  248. {
  249. $this->fijado = $fijado;
  250. return $this;
  251. }
  252. public function isFijado(): bool
  253. {
  254. return $this->fijado ?? false;
  255. }
  256. }