src/Core/Entity/Chat/Conversacion.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity\Chat;
  3. use App\Core\Entity\Curso;
  4. use App\Core\Repository\Chat\ConversacionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=ConversacionRepository::class)
  10. */
  11. class Conversacion
  12. {
  13. /**
  14. * @ORM\Id()
  15. * @ORM\GeneratedValue()
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity=Curso::class, inversedBy="conversaciones")
  21. */
  22. private $curso;
  23. /**
  24. * @ORM\Column(type="string", length=100, nullable=true)
  25. */
  26. private $nombre;
  27. /**
  28. * @ORM\OneToMany(targetEntity=Participante::class, mappedBy="conversacion", orphanRemoval=true)
  29. */
  30. private $participantes;
  31. /**
  32. * @ORM\OneToMany(targetEntity=Mensaje::class, mappedBy="conversacion", orphanRemoval=true)
  33. */
  34. private $mensajes;
  35. /**
  36. * @ORM\OneToOne (targetEntity=Mensaje::class)
  37. * @ORM\JoinColumn(nullable=true)
  38. */
  39. private $ultimoMensaje;
  40. /**
  41. * @ORM\Column(type="integer", options={"default": 0})
  42. * 0 = aprobada, default cuando es conversacion de curso
  43. * 1 = en espera de aprobacion (solicitud de conversacion)
  44. */
  45. private $estado = 0;
  46. public function __construct()
  47. {
  48. $this->participantes = new ArrayCollection();
  49. $this->mensajes = new ArrayCollection();
  50. }
  51. public function getId(): ?int
  52. {
  53. return $this->id;
  54. }
  55. public function getCurso(): ?Curso
  56. {
  57. return $this->curso;
  58. }
  59. public function setCurso(?Curso $curso): self
  60. {
  61. $this->curso = $curso;
  62. return $this;
  63. }
  64. public function getNombre(): ?string
  65. {
  66. return $this->nombre;
  67. }
  68. public function setNombre(?string $nombre): self
  69. {
  70. $this->nombre = $nombre;
  71. return $this;
  72. }
  73. /**
  74. * @return Collection|Participante[]
  75. */
  76. public function getParticipantes(): Collection
  77. {
  78. return $this->participantes;
  79. }
  80. public function addParticipante(Participante $participante): self
  81. {
  82. if (!$this->participantes->contains($participante)) {
  83. $this->participantes[] = $participante;
  84. $participante->setConversacion($this);
  85. }
  86. return $this;
  87. }
  88. public function removeParticipante(Participante $participante): self
  89. {
  90. if ($this->participantes->contains($participante)) {
  91. $this->participantes->removeElement($participante);
  92. // set the owning side to null (unless already changed)
  93. if ($participante->getConversacion() === $this) {
  94. $participante->setConversacion(null);
  95. }
  96. }
  97. return $this;
  98. }
  99. /**
  100. * @return Collection|Mensaje[]
  101. */
  102. public function getMensajes(): Collection
  103. {
  104. return $this->mensajes;
  105. }
  106. public function addMensaje(Mensaje $mensaje): self
  107. {
  108. if (!$this->mensajes->contains($mensaje)) {
  109. $this->mensajes[] = $mensaje;
  110. $mensaje->setConversacion($this);
  111. }
  112. return $this;
  113. }
  114. public function removeMensaje(Mensaje $mensaje): self
  115. {
  116. if ($this->mensajes->contains($mensaje)) {
  117. $this->mensajes->removeElement($mensaje);
  118. // set the owning side to null (unless already changed)
  119. if ($mensaje->getConversacion() === $this) {
  120. $mensaje->setConversacion(null);
  121. }
  122. }
  123. return $this;
  124. }
  125. public function getUltimoMensaje(): ?Mensaje
  126. {
  127. return $this->ultimoMensaje;
  128. }
  129. public function setUltimoMensaje(?Mensaje $ultimoMensaje): self
  130. {
  131. $this->ultimoMensaje = $ultimoMensaje;
  132. return $this;
  133. }
  134. public function getEstado(): ?int
  135. {
  136. return $this->estado;
  137. }
  138. public function setEstado(int $estado): self
  139. {
  140. $this->estado = $estado;
  141. return $this;
  142. }
  143. }