src/Core/Entity/Chat/Mensaje.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity\Chat;
  3. use App\Core\Repository\Chat\MensajeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\ORM\Mapping\Index;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. /**
  10. * @ORM\Entity(repositoryClass=MensajeRepository::class)
  11. * @ORM\Table(indexes={@Index(name="created_at_index", columns={"created_at"})})
  12. * @Vich\Uploadable()
  13. */
  14. class Mensaje
  15. {
  16. /**
  17. * @ORM\Id()
  18. * @ORM\GeneratedValue()
  19. * @ORM\Column(type="integer")
  20. */
  21. private $id;
  22. /**
  23. * @ORM\Column(type="text", nullable=true)
  24. */
  25. private $contenido;
  26. /**
  27. * @ORM\ManyToOne(targetEntity=Participante::class, inversedBy="mensajes")
  28. * @ORM\JoinColumn(nullable=false)
  29. */
  30. private $participante;
  31. /**
  32. * @ORM\ManyToOne(targetEntity=Conversacion::class, inversedBy="mensajes")
  33. * @ORM\JoinColumn(nullable=false)
  34. */
  35. private $conversacion;
  36. /**
  37. * @ORM\Column(type="datetime")
  38. */
  39. private $createdAt;
  40. private $mensajePropio;
  41. /**
  42. * NOTE: This is not a mapped field of entity metadata, just a simple property.
  43. *
  44. * @Vich\UploadableField(mapping="archivo_mensaje", fileNameProperty="nombreArchivo", size="tamanioArchivo")
  45. *
  46. * @var File|null
  47. */
  48. private $archivo;
  49. /**
  50. * @ORM\Column(type="string", length=200, nullable=true)
  51. *
  52. * @var string|null
  53. */
  54. private $nombreArchivo;
  55. /**
  56. * @ORM\Column(type="integer", nullable=true)
  57. *
  58. * @var int|null
  59. */
  60. private $tamanioArchivo;
  61. public function getId(): ?int
  62. {
  63. return $this->id;
  64. }
  65. public function getContenido(): ?string
  66. {
  67. return $this->contenido;
  68. }
  69. public function setContenido(?string $contenido): self
  70. {
  71. $this->contenido = $contenido;
  72. return $this;
  73. }
  74. public function getParticipante(): ?Participante
  75. {
  76. return $this->participante;
  77. }
  78. public function setParticipante(?Participante $participante): self
  79. {
  80. $this->participante = $participante;
  81. return $this;
  82. }
  83. public function getConversacion(): ?Conversacion
  84. {
  85. return $this->conversacion;
  86. }
  87. public function setConversacion(?Conversacion $conversacion): self
  88. {
  89. $this->conversacion = $conversacion;
  90. return $this;
  91. }
  92. public function getCreatedAt(): ?\DateTimeInterface
  93. {
  94. return $this->createdAt;
  95. }
  96. public function setCreatedAt(\DateTimeInterface $createdAt): self
  97. {
  98. $this->createdAt = $createdAt;
  99. return $this;
  100. }
  101. /**
  102. * @return boolean
  103. */
  104. public function getMensajePropio()
  105. {
  106. return $this->mensajePropio;
  107. }
  108. /**
  109. * @param boolean $mensajePropio
  110. */
  111. public function setMensajePropio(bool $mensajePropio): void
  112. {
  113. $this->mensajePropio = $mensajePropio;
  114. }
  115. /**
  116. * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  117. * of 'UploadedFile' is injected into this setter to trigger the update. If this
  118. * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  119. * must be able to accept an instance of 'File' as the bundle will inject one here
  120. * during Doctrine hydration.
  121. *
  122. * @param File|UploadedFile|null $uploadedFile
  123. */
  124. public function setArchivo(?File $archivo = null): void
  125. {
  126. $this->archivo = $archivo;
  127. if (null !== $archivo) {
  128. // It is required that at least one field changes if you are using doctrine
  129. // otherwise the event listeners won't be called and the file is lost
  130. $this->setTamanioArchivo($archivo->getSize());
  131. }
  132. }
  133. public function getArchivo(): ?File
  134. {
  135. return $this->archivo;
  136. }
  137. public function setNombreArchivo(?string $nombreArchivo): void
  138. {
  139. $this->nombreArchivo = $nombreArchivo;
  140. }
  141. public function getNombreArchivo(): ?string
  142. {
  143. return $this->nombreArchivo;
  144. }
  145. public function setTamanioArchivo(?int $tamanioArchivo): void
  146. {
  147. $this->tamanioArchivo = $tamanioArchivo;
  148. }
  149. public function getTamanioArchivo(): ?int
  150. {
  151. return $this->tamanioArchivo;
  152. }
  153. }