src/Entity/BattleComment.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BattleCommentRepository;
  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(repositoryClassBattleCommentRepository::class)]
  9. class BattleComment
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(inversedBy'comments')]
  16.     private ?Battle $battle null;
  17.     #[ORM\OneToMany(mappedBy'battleComment'targetEntityBattleCommentLike::class,cascade: ["remove","persist"])]
  18.     private Collection $likes;
  19.     #[ORM\Column(typeTypes::TEXT)]
  20.     private ?string $message null;
  21.     #[ORM\ManyToOne(inversedBy'battleComments')]
  22.     private ?Client $sender null;
  23.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  24.     private ?\DateTimeInterface $createdAt null;
  25.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  26.     private ?\DateTimeInterface $updatedAt null;
  27.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'replies')]
  28.     private ?self $replyCommentRoot null;
  29.     #[ORM\OneToMany(mappedBy'replyCommentRoot'targetEntityself::class)]
  30.     private Collection $replies;
  31.     public function __construct()
  32.     {
  33.         $this->likes = new ArrayCollection();
  34.         $this->replies = new ArrayCollection();
  35.     }
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getBattle(): ?Battle
  41.     {
  42.         return $this->battle;
  43.     }
  44.     public function setBattle(?Battle $battle): static
  45.     {
  46.         $this->battle $battle;
  47.         return $this;
  48.     }
  49.     /**
  50.      * @return Collection<int, BattleCommentLike>
  51.      */
  52.     public function getLikes(): Collection
  53.     {
  54.         return $this->likes;
  55.     }
  56.     public function addLike(BattleCommentLike $like): static
  57.     {
  58.         if (!$this->likes->contains($like)) {
  59.             $this->likes->add($like);
  60.             $like->setBattleComment($this);
  61.         }
  62.         return $this;
  63.     }
  64.     public function removeLike(BattleCommentLike $like): static
  65.     {
  66.         if ($this->likes->removeElement($like)) {
  67.             // set the owning side to null (unless already changed)
  68.             if ($like->getBattleComment() === $this) {
  69.                 $like->setBattleComment(null);
  70.             }
  71.         }
  72.         return $this;
  73.     }
  74.     public function getMessage(): ?string
  75.     {
  76.         return $this->message;
  77.     }
  78.     public function setMessage(string $message): static
  79.     {
  80.         $this->message $message;
  81.         return $this;
  82.     }
  83.     public function getSender(): ?Client
  84.     {
  85.         return $this->sender;
  86.     }
  87.     public function setSender(?Client $sender): static
  88.     {
  89.         $this->sender $sender;
  90.         return $this;
  91.     }
  92.     public function getCreatedAt(): ?\DateTimeInterface
  93.     {
  94.         return $this->createdAt;
  95.     }
  96.     public function setCreatedAt(?\DateTimeInterface $createdAt): static
  97.     {
  98.         $this->createdAt $createdAt;
  99.         return $this;
  100.     }
  101.     public function getUpdatedAt(): ?\DateTimeInterface
  102.     {
  103.         return $this->updatedAt;
  104.     }
  105.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  106.     {
  107.         $this->updatedAt $updatedAt;
  108.         return $this;
  109.     }
  110.     public function getReplyCommentRoot(): ?self
  111.     {
  112.         return $this->replyCommentRoot;
  113.     }
  114.     public function setReplyCommentRoot(?self $replyCommentRoot): static
  115.     {
  116.         $this->replyCommentRoot $replyCommentRoot;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection<int, self>
  121.      */
  122.     public function getReplies(): Collection
  123.     {
  124.         return $this->replies;
  125.     }
  126.     public function addReply(self $reply): static
  127.     {
  128.         if (!$this->replies->contains($reply)) {
  129.             $this->replies->add($reply);
  130.             $reply->setReplyCommentRoot($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeReply(self $reply): static
  135.     {
  136.         if ($this->replies->removeElement($reply)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($reply->getReplyCommentRoot() === $this) {
  139.                 $reply->setReplyCommentRoot(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144. }