src/Entity/Comment.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CommentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CommentRepository::class)
  9.  */
  10. class Comment
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="text", nullable=true)
  20.      */
  21.     private $description;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Document::class, inversedBy="comments")
  24.      */
  25.     private $document;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=Comment::class, inversedBy="comments")
  28.      */
  29.     private $childComment;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="childComment")
  32.      */
  33.     private $comments;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="comments")
  36.      */
  37.     private $user;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=Document::class, inversedBy="documentComments")
  40.      */
  41.     private $documentComment;
  42.     /**
  43.      * @ORM\Column(type="datetime")
  44.      */
  45.     private $createAt;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=Produit::class, inversedBy="comments")
  48.      */
  49.     private $produit;
  50.     public function __construct()
  51.     {
  52.         $this->comments = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getDescription(): ?string
  59.     {
  60.         return $this->description;
  61.     }
  62.     public function setDescription(?string $description): self
  63.     {
  64.         $this->description $description;
  65.         return $this;
  66.     }
  67.     public function getDocument(): ?Document
  68.     {
  69.         return $this->document;
  70.     }
  71.     public function setDocument(?Document $document): self
  72.     {
  73.         $this->document $document;
  74.         return $this;
  75.     }
  76.     public function getChildComment(): ?self
  77.     {
  78.         return $this->childComment;
  79.     }
  80.     public function setChildComment(?self $childComment): self
  81.     {
  82.         $this->childComment $childComment;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection|self[]
  87.      */
  88.     public function getComments(): Collection
  89.     {
  90.         return $this->comments;
  91.     }
  92.     public function addComment(self $comment): self
  93.     {
  94.         if (!$this->comments->contains($comment)) {
  95.             $this->comments[] = $comment;
  96.             $comment->setChildComment($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeComment(self $comment): self
  101.     {
  102.         if ($this->comments->removeElement($comment)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($comment->getChildComment() === $this) {
  105.                 $comment->setChildComment(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110.     public function getUser(): ?User
  111.     {
  112.         return $this->user;
  113.     }
  114.     public function setUser(?User $user): self
  115.     {
  116.         $this->user $user;
  117.         return $this;
  118.     }
  119.     public function getDocumentComment(): ?Document
  120.     {
  121.         return $this->documentComment;
  122.     }
  123.     public function setDocumentComment(?Document $documentComment): self
  124.     {
  125.         $this->documentComment $documentComment;
  126.         return $this;
  127.     }
  128.     public function getCreateAt(): ?\DateTimeInterface
  129.     {
  130.         return $this->createAt;
  131.     }
  132.     public function setCreateAt(\DateTimeInterface $createAt): self
  133.     {
  134.         $this->createAt $createAt;
  135.         return $this;
  136.     }
  137.     public function getProduit(): ?Produit
  138.     {
  139.         return $this->produit;
  140.     }
  141.     public function setProduit(?Produit $produit): self
  142.     {
  143.         $this->produit $produit;
  144.         return $this;
  145.     }
  146. }