<?phpnamespace App\Entity;use App\Entity\Media\Media;use App\Entity\Program\Program;use App\Repository\ChatsRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ChatsRepository::class) * @ORM\HasLifecycleCallbacks() */class Chats extends BaseEntity{ /** * @ORM\ManyToOne(targetEntity="App\Entity\Media\Media", inversedBy="chats") * @ORM\JoinColumn(onDelete="CASCADE") */ private $media; /** * @ORM\ManyToOne(targetEntity="App\Entity\Program\Program", inversedBy="chats") * @ORM\JoinColumn(onDelete="CASCADE") */ private $program; /** * @ORM\ManyToOne(targetEntity="App\Entity\User") * @ORM\JoinColumn(onDelete="CASCADE") */ private $user; /** * @ORM\OneToMany(targetEntity="App\Entity\ChatsContent",mappedBy="chat",cascade={"persist"}, orphanRemoval=true) */ private $contents; /** * @ORM\Column(type="integer", nullable=false) */ private $numberMessageNonLuForUser; /** * @ORM\Column(type="integer", nullable=false) * retourne de message envoyé a une media ou un program non lu */ private $numberMessageNonLuForChannel; /** * @ORM\Column(type="datetime", options={"default" = "CURRENT_TIMESTAMP"}) */ protected $lastMessageDate; public function __construct() { $this->contents = new ArrayCollection(); $this->numberMessageNonLuForUser = 0; $this->numberMessageNonLuForChannel = 0; } public function getId(): ?int { return $this->id; } public function getMedia(): ?Media { return $this->media; } public function setMedia(?Media $media): self { $this->media = $media; return $this; } public function getProgram(): ?Program { return $this->program; } public function setProgram(?Program $program): self { $this->program = $program; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } /** * @return Collection|ChatsContent[] */ public function getContents(): Collection { return $this->contents; } public function addContent(ChatsContent $content): self { if (!$this->contents->contains($content)) { $this->contents[] = $content; $content->setChat($this); } return $this; } public function removeContent(ChatsContent $content): self { if ($this->contents->removeElement($content)) { // set the owning side to null (unless already changed) if ($content->getChat() === $this) { $content->setChat(null); } } return $this; } public function getNumberMessageNonLuForUser(): ?int { return $this->numberMessageNonLuForUser; } public function setNumberMessageNonLuForUser(int $numberMessageNonLuForUser): self { $this->numberMessageNonLuForUser = $numberMessageNonLuForUser; return $this; } public function getLastMessageDate(): ?\DateTimeInterface { return $this->lastMessageDate; } public function setLastMessageDate(\DateTimeInterface $lastMessageDate): self { $this->lastMessageDate = $lastMessageDate; return $this; } public function getNumberMessageNonLuForChannel(): ?int { return $this->numberMessageNonLuForChannel; } public function setNumberMessageNonLuForChannel(int $numberMessageNonLuForChannel): self { $this->numberMessageNonLuForChannel = $numberMessageNonLuForChannel; return $this; }}