<?phpnamespace App\Core\Entity\Chat;use App\Core\Entity\Curso;use App\Core\Repository\Chat\ConversacionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ConversacionRepository::class) */class Conversacion{ /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity=Curso::class, inversedBy="conversaciones") */ private $curso; /** * @ORM\Column(type="string", length=100, nullable=true) */ private $nombre; /** * @ORM\OneToMany(targetEntity=Participante::class, mappedBy="conversacion", orphanRemoval=true) */ private $participantes; /** * @ORM\OneToMany(targetEntity=Mensaje::class, mappedBy="conversacion", orphanRemoval=true) */ private $mensajes; /** * @ORM\OneToOne (targetEntity=Mensaje::class) * @ORM\JoinColumn(nullable=true) */ private $ultimoMensaje; /** * @ORM\Column(type="integer", options={"default": 0}) * 0 = aprobada, default cuando es conversacion de curso * 1 = en espera de aprobacion (solicitud de conversacion) */ private $estado = 0; public function __construct() { $this->participantes = new ArrayCollection(); $this->mensajes = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getCurso(): ?Curso { return $this->curso; } public function setCurso(?Curso $curso): self { $this->curso = $curso; return $this; } public function getNombre(): ?string { return $this->nombre; } public function setNombre(?string $nombre): self { $this->nombre = $nombre; return $this; } /** * @return Collection|Participante[] */ public function getParticipantes(): Collection { return $this->participantes; } public function addParticipante(Participante $participante): self { if (!$this->participantes->contains($participante)) { $this->participantes[] = $participante; $participante->setConversacion($this); } return $this; } public function removeParticipante(Participante $participante): self { if ($this->participantes->contains($participante)) { $this->participantes->removeElement($participante); // set the owning side to null (unless already changed) if ($participante->getConversacion() === $this) { $participante->setConversacion(null); } } return $this; } /** * @return Collection|Mensaje[] */ public function getMensajes(): Collection { return $this->mensajes; } public function addMensaje(Mensaje $mensaje): self { if (!$this->mensajes->contains($mensaje)) { $this->mensajes[] = $mensaje; $mensaje->setConversacion($this); } return $this; } public function removeMensaje(Mensaje $mensaje): self { if ($this->mensajes->contains($mensaje)) { $this->mensajes->removeElement($mensaje); // set the owning side to null (unless already changed) if ($mensaje->getConversacion() === $this) { $mensaje->setConversacion(null); } } return $this; } public function getUltimoMensaje(): ?Mensaje { return $this->ultimoMensaje; } public function setUltimoMensaje(?Mensaje $ultimoMensaje): self { $this->ultimoMensaje = $ultimoMensaje; return $this; } public function getEstado(): ?int { return $this->estado; } public function setEstado(int $estado): self { $this->estado = $estado; return $this; }}