<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\DiscussionClassMessageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: DiscussionClassMessageRepository::class)]
#[ORM\HasLifecycleCallbacks]
class DiscussionClassMessage
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'discussionClassMessages')]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?DiscussionClass $discussion = null;
#[ORM\ManyToOne(inversedBy: 'discussionClassMessages')]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?User $author = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?string $message = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?string $file_name = null;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'discussionClassMessages')]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?self $replyToMessage = null;
#[ORM\OneToMany(mappedBy: 'replyToMessage', targetEntity: self::class)]
private Collection $discussionClassMessages;
#[ORM\Column(nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?int $size = null;
#[ORM\Column(nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?int $duration = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?string $cachedSenderPath = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionMessage'])]
private ?string $cachedReciverPath = null;
#[ORM\Column(nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?string $localId = null;
#[ORM\Column(length: 255)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?string $type = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['getDiscussionClass', 'getDiscussionClassMessage'])]
private ?string $url = null;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'discussionClassMessagesRead')]
private Collection $readers;
public function __construct()
{
$this->discussionClassMessages = new ArrayCollection();
$this->readers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDiscussion(): ?DiscussionClass
{
return $this->discussion;
}
public function setDiscussion(?DiscussionClass $discussion): static
{
$this->discussion = $discussion;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage(?string $message): static
{
$this->message = $message;
return $this;
}
public function getFileName(): ?string
{
return $this->file_name;
}
public function setFileName(?string $file_name): static
{
$this->file_name = $file_name;
return $this;
}
public function getReplyToMessage(): ?self
{
return $this->replyToMessage;
}
public function setReplyToMessage(?self $replyToMessage): static
{
$this->replyToMessage = $replyToMessage;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getDiscussionClassMessages(): Collection
{
return $this->discussionClassMessages;
}
public function addDiscussionClassMessage(self $discussionClassMessage): static
{
if (!$this->discussionClassMessages->contains($discussionClassMessage)) {
$this->discussionClassMessages->add($discussionClassMessage);
$discussionClassMessage->setReplyToMessage($this);
}
return $this;
}
public function removeDiscussionClassMessage(self $discussionClassMessage): static
{
if ($this->discussionClassMessages->removeElement($discussionClassMessage)) {
// set the owning side to null (unless already changed)
if ($discussionClassMessage->getReplyToMessage() === $this) {
$discussionClassMessage->setReplyToMessage(null);
}
}
return $this;
}
public function getSize(): ?int
{
return $this->size;
}
public function setSize(?int $size): static
{
$this->size = $size;
return $this;
}
public function getDuration(): ?int
{
return $this->duration;
}
public function setDuration(?int $duration): static
{
$this->duration = $duration;
return $this;
}
public function getCachedSenderPath(): ?string
{
return $this->cachedSenderPath;
}
public function setCachedSenderPath(?string $cachedSenderPath): static
{
$this->cachedSenderPath = $cachedSenderPath;
return $this;
}
public function getCachedReciverPath(): ?string
{
return $this->cachedReciverPath;
}
public function setCachedReciverPath(?string $cachedReciverPath): static
{
$this->cachedReciverPath = $cachedReciverPath;
return $this;
}
public function getLocalId(): ?string
{
return $this->localId;
}
public function setLocalId(?string $localId): static
{
$this->localId = $localId;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): static
{
$this->type = $type;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): static
{
$this->url = $url;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getReaders(): Collection
{
return $this->readers;
}
public function addReader(User $reader): static
{
if (!$this->readers->contains($reader)) {
$this->readers->add($reader);
}
return $this;
}
public function removeReader(User $reader): static
{
$this->readers->removeElement($reader);
return $this;
}
}