src/Entity/CommentElearning.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentElearningRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCommentElearningRepository::class)]
  9. class CommentElearning
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  16.     private ?string $message null;
  17.     #[ORM\ManyToOne(inversedBy'commentElearnings')]
  18.     private ?User $user null;
  19.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  20.     private ?\DateTimeInterface $date null;
  21.     #[ORM\ManyToOne(inversedBy'commentElearnings')]
  22.     private ?VideoElearning $video null;
  23.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'replies')]
  24.     private ?self $parent null;
  25.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class,cascade: ['remove'])]
  26.     private Collection $replies;
  27.     #[ORM\ManyToMany(targetEntityUser::class, inversedBy'commentLikes')]
  28.     private Collection $likedBy;
  29.     public function __construct()
  30.     {
  31.         $this->replies = new ArrayCollection();
  32.         $this->likedBy = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getMessage(): ?string
  39.     {
  40.         return $this->message;
  41.     }
  42.     public function setMessage(?string $message): self
  43.     {
  44.         $this->message $message;
  45.         return $this;
  46.     }
  47.     public function getUser(): ?User
  48.     {
  49.         return $this->user;
  50.     }
  51.     public function setUser(?User $user): self
  52.     {
  53.         $this->user $user;
  54.         return $this;
  55.     }
  56.     public function getDate(): ?\DateTimeInterface
  57.     {
  58.         return $this->date;
  59.     }
  60.     public function setDate(?\DateTimeInterface $date): self
  61.     {
  62.         $this->date $date;
  63.         return $this;
  64.     }
  65.     public function getVideo(): ?VideoElearning
  66.     {
  67.         return $this->video;
  68.     }
  69.     public function setVideo(?VideoElearning $video): self
  70.     {
  71.         $this->video $video;
  72.         return $this;
  73.     }
  74.     public function getParent(): ?self
  75.     {
  76.         return $this->parent;
  77.     }
  78.     public function setParent(?self $parent): self
  79.     {
  80.         $this->parent $parent;
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return Collection<int, self>
  85.      */
  86.     public function getReplies(): Collection
  87.     {
  88.         return $this->replies;
  89.     }
  90.     public function addReply(self $reply): self
  91.     {
  92.         if (!$this->replies->contains($reply)) {
  93.             $this->replies->add($reply);
  94.             $reply->setParent($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeReply(self $reply): self
  99.     {
  100.         if ($this->replies->removeElement($reply)) {
  101.             // set the owning side to null (unless already changed)
  102.             if ($reply->getParent() === $this) {
  103.                 $reply->setParent(null);
  104.             }
  105.         }
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection<int, User>
  110.      */
  111.     public function getLikedBy(): Collection
  112.     {
  113.         return $this->likedBy;
  114.     }
  115.     public function addLikedBy(User $likedBy): self
  116.     {
  117.         if (!$this->likedBy->contains($likedBy)) {
  118.             $this->likedBy->add($likedBy);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeLikedBy(User $likedBy): self
  123.     {
  124.         $this->likedBy->removeElement($likedBy);
  125.         return $this;
  126.     }
  127.     public function getLikesCount(): int { return $this->likedBy->count(); }
  128.     public function isLikedByUser(User $user): bool { return $this->likedBy->contains($user); }
  129. }