<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*/
class Tema extends \App\Entity\BaseEntity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $titulo;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $numeroRespuestas;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $numeroVisitas;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $estado;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $descripcion;
/**
* @ORM\Column(
* type="json",
* nullable=true,
* options={"comment":"Indica para que roles está disponible el tema, null === public"}
* )
*/
private $available;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":false})
*/
private $fijado;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\MensajeForo::class, mappedBy="tema")
*/
private $mensajeForos;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\PropietarioContenido::class, inversedBy="temas")
* @ORM\JoinColumn(name="propietario_contenido_id", referencedColumnName="id")
*/
private $propietarioContenido;
/**
* @ORM\ManyToOne(targetEntity=\App\Entity\CategoriaForo::class, inversedBy="temas")
* @ORM\JoinColumn(name="categoria_foro_id", referencedColumnName="id")
*/
private $categoriaForo;
/**
* No es un campo de Doctrine. Se usará para almacenar temporalmente la fecha del último mensaje.
*/
private $lastMessageDate = null;
/**
* No es un campo de Doctrine. Se usará para almacenar temporalmente si el tema tiene mensajes no leídos.
*/
private $hasUnread = false;
/**
* No es un campo de Doctrine. Se usará para almacenar temporalmente si el tema es completamente nuevo (nunca visitado).
*/
private $isNew = false;
public function __construct()
{
$this->mensajeForos = new ArrayCollection();
}
public function __toString(): string
{
return $this->getTitulo()?? '--';
}
public function getId(): ?int
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
return $this;
}
public function getTitulo(): ?string
{
return $this->titulo;
}
public function setTitulo(?string $titulo): static
{
$this->titulo = $titulo;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getNumeroRespuestas(): ?int
{
return $this->mensajeForos->count();
}
public function setNumeroRespuestas(?int $numeroRespuestas): static
{
$this->numeroRespuestas = $numeroRespuestas;
return $this;
}
public function getNumeroVisitas(): ?int
{
return $this->numeroVisitas;
}
public function setNumeroVisitas(?int $numeroVisitas): static
{
$this->numeroVisitas = $numeroVisitas;
return $this;
}
public function getEstado(): ?string
{
return $this->estado;
}
public function setEstado(?string $estado): static
{
$this->estado = $estado;
return $this;
}
public function getDescripcion(): ?string
{
return $this->descripcion;
}
public function setDescripcion(?string $descripcion): static
{
$this->descripcion = $descripcion;
return $this;
}
/**
* @return Collection<int, MensajeForo>
*/
public function getMensajeForos(): Collection
{
return $this->mensajeForos;
}
public function addMensajeForo(MensajeForo $mensajeForo): static
{
if (!$this->mensajeForos->contains($mensajeForo)) {
$this->mensajeForos->add($mensajeForo);
$mensajeForo->setTema($this);
}
return $this;
}
public function removeMensajeForo(MensajeForo $mensajeForo): static
{
if ($this->mensajeForos->removeElement($mensajeForo)) {
// set the owning side to null (unless already changed)
if ($mensajeForo->getTema() === $this) {
$mensajeForo->setTema(null);
}
}
return $this;
}
public function getPropietarioContenido(): ?PropietarioContenido
{
return $this->propietarioContenido;
}
public function setPropietarioContenido(?PropietarioContenido $propietarioContenido): static
{
$this->propietarioContenido = $propietarioContenido;
return $this;
}
public function getAvailable(): ?array
{
return $this->available;
}
public function setAvailable(?array $available): static
{
$this->available = $available;
return $this;
}
public function getLastMessageDate(): ?\DateTimeInterface
{
return $this->lastMessageDate;
}
public function setLastMessageDate(?\DateTimeInterface $lastMessageDate): static
{
$this->lastMessageDate = $lastMessageDate;
return $this;
}
public function getHasUnread(): bool
{
return $this->hasUnread;
}
public function setHasUnread(bool $hasUnread): static
{
$this->hasUnread = $hasUnread;
return $this;
}
public function getIsNew(): bool
{
return $this->isNew;
}
public function setIsNew(bool $isNew): static
{
$this->isNew = $isNew;
return $this;
}
public function getCategoriaForo(): ?CategoriaForo
{
return $this->categoriaForo;
}
public function setCategoriaForo(?CategoriaForo $categoriaForo): static
{
$this->categoriaForo = $categoriaForo;
return $this;
}
public function getFijado(): ?bool
{
return $this->fijado;
}
public function setFijado(?bool $fijado): static
{
$this->fijado = $fijado;
return $this;
}
public function isFijado(): bool
{
return $this->fijado ?? false;
}
}