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

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity\Chat;
  3. use App\Core\Entity\User;
  4. use App\Core\Repository\Chat\ParticipanteRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=ParticipanteRepository::class)
  10. */
  11. class Participante
  12. {
  13. /**
  14. * @ORM\Id()
  15. * @ORM\GeneratedValue()
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity=Conversacion::class, inversedBy="participantes")
  21. * @ORM\JoinColumn(nullable=false)
  22. */
  23. private $conversacion;
  24. /**
  25. * @ORM\Column(type="boolean", nullable=true)
  26. */
  27. private $administrador;
  28. /**
  29. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="participacionesChat")
  30. * @ORM\JoinColumn(nullable=false)
  31. */
  32. private $usuario;
  33. /**
  34. * @ORM\Column(type="datetime", nullable=true)
  35. */
  36. private $mensajesLeidosAt;
  37. /**
  38. * @ORM\OneToMany(targetEntity=Mensaje::class, mappedBy="participante", orphanRemoval=true)
  39. */
  40. private $mensajes;
  41. public function __construct()
  42. {
  43. $this->mensajes = new ArrayCollection();
  44. }
  45. public function getId(): ?int
  46. {
  47. return $this->id;
  48. }
  49. public function getConversacion(): ?Conversacion
  50. {
  51. return $this->conversacion;
  52. }
  53. public function setConversacion(?Conversacion $conversacion): self
  54. {
  55. $this->conversacion = $conversacion;
  56. return $this;
  57. }
  58. public function getAdministrador(): ?bool
  59. {
  60. return $this->administrador;
  61. }
  62. public function setAdministrador(?bool $administrador): self
  63. {
  64. $this->administrador = $administrador;
  65. return $this;
  66. }
  67. public function getUsuario(): ?User
  68. {
  69. return $this->usuario;
  70. }
  71. public function setUsuario(?User $usuario): self
  72. {
  73. $this->usuario = $usuario;
  74. return $this;
  75. }
  76. public function getMensajesLeidosAt(): ?\DateTimeInterface
  77. {
  78. return $this->mensajesLeidosAt;
  79. }
  80. public function setMensajesLeidosAt(?\DateTimeInterface $mensajesLeidosAt): self
  81. {
  82. $this->mensajesLeidosAt = $mensajesLeidosAt;
  83. return $this;
  84. }
  85. /**
  86. * @return Collection|Mensaje[]
  87. */
  88. public function getMensajes(): Collection
  89. {
  90. return $this->mensajes;
  91. }
  92. public function addMensaje(Mensaje $mensaje): self
  93. {
  94. if (!$this->mensajes->contains($mensaje)) {
  95. $this->mensajes[] = $mensaje;
  96. $mensaje->setParticipante($this);
  97. }
  98. return $this;
  99. }
  100. public function removeMensaje(Mensaje $mensaje): self
  101. {
  102. if ($this->mensajes->contains($mensaje)) {
  103. $this->mensajes->removeElement($mensaje);
  104. // set the owning side to null (unless already changed)
  105. if ($mensaje->getParticipante() === $this) {
  106. $mensaje->setParticipante(null);
  107. }
  108. }
  109. return $this;
  110. }
  111. }