<?php
namespace App\Entity;
use App\Repository\ConversationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
/**
* @ORM\Entity(repositoryClass=ConversationRepository::class)
*/
class Conversation
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $uuid;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $token;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $slug;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $statut = false;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="conversations")
*/
private $interlocuteur;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $genre;
/**
* @ORM\ManyToOne(targetEntity=Post::class, inversedBy="conversations")
*/
private $post;
/**
* @ORM\ManyToOne(targetEntity=Agora::class, inversedBy="conversations")
*/
private $agora;
/**
* @ORM\OneToMany(targetEntity=Messagerie::class, mappedBy="conversation")
*/
private $messageries;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="conversationsUser")
*/
private $user;
public function __construct()
{
$this->uuid = Uuid::v4();
$this->messageries = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUuid(): ?string
{
return $this->uuid;
}
public function setUuid(?string $uuid): self
{
$this->uuid = $uuid;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function isStatut(): ?bool
{
return $this->statut;
}
public function setStatut(?bool $statut): self
{
$this->statut = $statut;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getInterlocuteur(): ?User
{
return $this->interlocuteur;
}
public function setInterlocuteur(?User $interlocuteur): self
{
$this->interlocuteur = $interlocuteur;
return $this;
}
public function getGenre(): ?string
{
return $this->genre;
}
public function setGenre(?string $genre): self
{
$this->genre = $genre;
return $this;
}
public function getPost(): ?Post
{
return $this->post;
}
public function setPost(?Post $post): self
{
$this->post = $post;
return $this;
}
public function getAgora(): ?Agora
{
return $this->agora;
}
public function setAgora(?Agora $agora): self
{
$this->agora = $agora;
return $this;
}
/**
* @return Collection<int, Messagerie>
*/
public function getMessageries(): Collection
{
return $this->messageries;
}
public function addMessagery(Messagerie $messagery): self
{
if (!$this->messageries->contains($messagery)) {
$this->messageries[] = $messagery;
$messagery->setConversation($this);
}
return $this;
}
public function removeMessagery(Messagerie $messagery): self
{
if ($this->messageries->removeElement($messagery)) {
// set the owning side to null (unless already changed)
if ($messagery->getConversation() === $this) {
$messagery->setConversation(null);
}
}
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}