<?php
namespace App\Entity;
use App\Repository\ChatMessageRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ChatMessageRepository::class)
* @ORM\Table(name="chat_message")
*/
class ChatMessage
{
// Équivalent de l'Enum en PHP 7.4
const TYPE_TEXT = 'text';
const TYPE_PDF = 'pdf';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $fileName;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $fileSize;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pdfUrl;
/**
* @ORM\Column(type="datetime")
*/
private $timestamp;
/**
* @ORM\Column(type="boolean")
*/
private bool $isMe = false;
/**
* @ORM\Column(type="string", length=20)
*/
private $type;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $managerName;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $managerContact;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $customerCode;
public function __construct()
{
$this->timestamp = new \DateTime();
}
// --- GETTERS & SETTERS ---
public function getId(): ?int
{
return $this->id;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
public function getFileSize(): ?string
{
return $this->fileSize;
}
public function setFileSize(?string $fileSize): self
{
$this->fileSize = $fileSize;
return $this;
}
public function getPdfUrl(): ?string
{
return $this->pdfUrl;
}
public function setPdfUrl(?string $pdfUrl): self
{
$this->pdfUrl = $pdfUrl;
return $this;
}
public function getTimestamp(): \DateTimeInterface
{
return $this->timestamp;
}
public function setTimestamp(\DateTimeInterface $timestamp): self
{
$this->timestamp = $timestamp;
return $this;
}
public function isMe(): bool
{
return $this->isMe;
}
public function setIsMe(bool $isMe): self
{
$this->isMe = $isMe;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
if (!in_array($type, [self::TYPE_TEXT, self::TYPE_PDF])) {
throw new \InvalidArgumentException("Type de message invalide");
}
$this->type = $type;
return $this;
}
public function getManagerName(): ?string
{
return $this->managerName;
}
public function setManagerName(?string $managerName): self
{
$this->managerName = $managerName;
return $this;
}
public function getManagerContact(): ?string
{
return $this->managerContact;
}
public function setManagerContact(?string $managerContact): self
{
$this->managerContact = $managerContact;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getCustomerCode(): ?string
{
return $this->customerCode;
}
public function setCustomerCode(?string $customerCode): self
{
$this->customerCode = $customerCode;
return $this;
}
}