<?php
namespace App\Core\Entity\Chat;
use App\Core\Repository\Chat\MensajeRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=MensajeRepository::class)
* @ORM\Table(indexes={@Index(name="created_at_index", columns={"created_at"})})
* @Vich\Uploadable()
*/
class Mensaje
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $contenido;
/**
* @ORM\ManyToOne(targetEntity=Participante::class, inversedBy="mensajes")
* @ORM\JoinColumn(nullable=false)
*/
private $participante;
/**
* @ORM\ManyToOne(targetEntity=Conversacion::class, inversedBy="mensajes")
* @ORM\JoinColumn(nullable=false)
*/
private $conversacion;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
private $mensajePropio;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="archivo_mensaje", fileNameProperty="nombreArchivo", size="tamanioArchivo")
*
* @var File|null
*/
private $archivo;
/**
* @ORM\Column(type="string", length=200, nullable=true)
*
* @var string|null
*/
private $nombreArchivo;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $tamanioArchivo;
public function getId(): ?int
{
return $this->id;
}
public function getContenido(): ?string
{
return $this->contenido;
}
public function setContenido(?string $contenido): self
{
$this->contenido = $contenido;
return $this;
}
public function getParticipante(): ?Participante
{
return $this->participante;
}
public function setParticipante(?Participante $participante): self
{
$this->participante = $participante;
return $this;
}
public function getConversacion(): ?Conversacion
{
return $this->conversacion;
}
public function setConversacion(?Conversacion $conversacion): self
{
$this->conversacion = $conversacion;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return boolean
*/
public function getMensajePropio()
{
return $this->mensajePropio;
}
/**
* @param boolean $mensajePropio
*/
public function setMensajePropio(bool $mensajePropio): void
{
$this->mensajePropio = $mensajePropio;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|UploadedFile|null $uploadedFile
*/
public function setArchivo(?File $archivo = null): void
{
$this->archivo = $archivo;
if (null !== $archivo) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->setTamanioArchivo($archivo->getSize());
}
}
public function getArchivo(): ?File
{
return $this->archivo;
}
public function setNombreArchivo(?string $nombreArchivo): void
{
$this->nombreArchivo = $nombreArchivo;
}
public function getNombreArchivo(): ?string
{
return $this->nombreArchivo;
}
public function setTamanioArchivo(?int $tamanioArchivo): void
{
$this->tamanioArchivo = $tamanioArchivo;
}
public function getTamanioArchivo(): ?int
{
return $this->tamanioArchivo;
}
}