<?phpnamespace App\Entity;use App\Repository\BattleCommentRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: BattleCommentRepository::class)]class BattleComment{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne(inversedBy: 'comments')] private ?Battle $battle = null; #[ORM\OneToMany(mappedBy: 'battleComment', targetEntity: BattleCommentLike::class,cascade: ["remove","persist"])] private Collection $likes; #[ORM\Column(type: Types::TEXT)] private ?string $message = null; #[ORM\ManyToOne(inversedBy: 'battleComments')] private ?Client $sender = null; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $createdAt = null; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $updatedAt = null; #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'replies')] private ?self $replyCommentRoot = null; #[ORM\OneToMany(mappedBy: 'replyCommentRoot', targetEntity: self::class)] private Collection $replies; public function __construct() { $this->likes = new ArrayCollection(); $this->replies = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getBattle(): ?Battle { return $this->battle; } public function setBattle(?Battle $battle): static { $this->battle = $battle; return $this; } /** * @return Collection<int, BattleCommentLike> */ public function getLikes(): Collection { return $this->likes; } public function addLike(BattleCommentLike $like): static { if (!$this->likes->contains($like)) { $this->likes->add($like); $like->setBattleComment($this); } return $this; } public function removeLike(BattleCommentLike $like): static { if ($this->likes->removeElement($like)) { // set the owning side to null (unless already changed) if ($like->getBattleComment() === $this) { $like->setBattleComment(null); } } return $this; } public function getMessage(): ?string { return $this->message; } public function setMessage(string $message): static { $this->message = $message; return $this; } public function getSender(): ?Client { return $this->sender; } public function setSender(?Client $sender): static { $this->sender = $sender; return $this; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } public function setCreatedAt(?\DateTimeInterface $createdAt): static { $this->createdAt = $createdAt; return $this; } public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } public function setUpdatedAt(?\DateTimeInterface $updatedAt): static { $this->updatedAt = $updatedAt; return $this; } public function getReplyCommentRoot(): ?self { return $this->replyCommentRoot; } public function setReplyCommentRoot(?self $replyCommentRoot): static { $this->replyCommentRoot = $replyCommentRoot; return $this; } /** * @return Collection<int, self> */ public function getReplies(): Collection { return $this->replies; } public function addReply(self $reply): static { if (!$this->replies->contains($reply)) { $this->replies->add($reply); $reply->setReplyCommentRoot($this); } return $this; } public function removeReply(self $reply): static { if ($this->replies->removeElement($reply)) { // set the owning side to null (unless already changed) if ($reply->getReplyCommentRoot() === $this) { $reply->setReplyCommentRoot(null); } } return $this; }}