<?phpnamespace App\Entity;use App\Repository\CommentElearningRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CommentElearningRepository::class)]class CommentElearning{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $message = null; #[ORM\ManyToOne(inversedBy: 'commentElearnings')] private ?User $user = null; #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $date = null; #[ORM\ManyToOne(inversedBy: 'commentElearnings')] private ?VideoElearning $video = null; #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'replies')] private ?self $parent = null; #[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class,cascade: ['remove'])] private Collection $replies; #[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'commentLikes')] private Collection $likedBy; public function __construct() { $this->replies = new ArrayCollection(); $this->likedBy = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getMessage(): ?string { return $this->message; } public function setMessage(?string $message): self { $this->message = $message; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): self { $this->user = $user; return $this; } public function getDate(): ?\DateTimeInterface { return $this->date; } public function setDate(?\DateTimeInterface $date): self { $this->date = $date; return $this; } public function getVideo(): ?VideoElearning { return $this->video; } public function setVideo(?VideoElearning $video): self { $this->video = $video; return $this; } public function getParent(): ?self { return $this->parent; } public function setParent(?self $parent): self { $this->parent = $parent; return $this; } /** * @return Collection<int, self> */ public function getReplies(): Collection { return $this->replies; } public function addReply(self $reply): self { if (!$this->replies->contains($reply)) { $this->replies->add($reply); $reply->setParent($this); } return $this; } public function removeReply(self $reply): self { if ($this->replies->removeElement($reply)) { // set the owning side to null (unless already changed) if ($reply->getParent() === $this) { $reply->setParent(null); } } return $this; } /** * @return Collection<int, User> */ public function getLikedBy(): Collection { return $this->likedBy; } public function addLikedBy(User $likedBy): self { if (!$this->likedBy->contains($likedBy)) { $this->likedBy->add($likedBy); } return $this; } public function removeLikedBy(User $likedBy): self { $this->likedBy->removeElement($likedBy); return $this; } public function getLikesCount(): int { return $this->likedBy->count(); } public function isLikedByUser(User $user): bool { return $this->likedBy->contains($user); }}