<?php
namespace App\Entity;
use App\Repository\MessageRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: MessageRepository::class)]
class Message
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Assert\NotBlank(message: "Le titre est obligatoire.")]
private $titre;
#[ORM\Column(type: 'text', nullable: true)]
#[Assert\NotBlank(message: "Le contenu est obligatoire.")]
private $contenus;
#[ORM\Column(type: 'json', nullable: true)]
private ?array $image = null;
#[ORM\Column(type: 'datetime_immutable')]
private $createdAt;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private $deletedAt;
#[ORM\Column(type: 'integer', nullable: true)]
private $status;
#[ORM\Column(type: 'string', length: 20, nullable: true)]
#[Assert\NotBlank(message: "Le téléphone est obligatoire.")]
private $telephone;
#[ORM\ManyToOne(targetEntity: Canal::class)]
private $id_canal;
#[ORM\ManyToOne(targetEntity: Conversation::class)]
private $id_conversation;
#[ORM\ManyToOne(targetEntity: TypeMessage::class)]
private $id_type_message;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $audio;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $document;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $video;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $latitude;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $longitude;
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(?string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getContenus(): ?string
{
return $this->contenus;
}
public function setContenus(?string $contenus): self
{
$this->contenus = $contenus;
return $this;
}
public function getImage(): ?array
{
return $this->image;
}
public function setImage(?array $image): self
{
$this->image = $image;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getDeletedAt(): ?\DateTimeImmutable
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeImmutable $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): self
{
$this->status = $status;
return $this;
}
public function getTelephone(): ?string
{
return $this->telephone;
}
public function setTelephone(?string $telephone): self
{
$this->telephone = $telephone;
return $this;
}
public function addImage(string $image): self
{
$images = $this->image ?? [];
$images[] = $image;
$this->image = $images;
return $this;
}
public function removeImage(string $image): self
{
if ($this->image !== null) {
$this->image = array_filter(
$this->image,
fn ($img) => $img !== $image
);
}
return $this;
}
public function getIdCanal(): ?Canal
{
return $this->id_canal;
}
public function setIdCanal(?Canal $id_canal): self
{
$this->id_canal = $id_canal;
return $this;
}
public function getIdConversation(): ?Conversation
{
return $this->id_conversation;
}
public function setIdConversation(?Conversation $id_conversation): self
{
$this->id_conversation = $id_conversation;
return $this;
}
public function getIdTypeMessage(): ?TypeMessage
{
return $this->id_type_message;
}
public function setIdTypeMessage(?TypeMessage $id_type_message): self
{
$this->id_type_message = $id_type_message;
return $this;
}
public function getAudio(): ?string
{
return $this->audio;
}
public function setAudio(?string $audio): self
{
$this->audio = $audio;
return $this;
}
public function getDocument(): ?string
{
return $this->document;
}
public function setDocument(?string $document): self
{
$this->document = $document;
return $this;
}
public function getVideo(): ?string
{
return $this->video;
}
public function setVideo(?string $video): self
{
$this->video = $video;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(?string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(?string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
}