src/Entity/Articles.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ArticlesRepository;
  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(repositoryClassArticlesRepository::class)]
  9. class Articles
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $Title null;
  17.     #[ORM\Column(typeTypes::TEXT)]
  18.     private ?string $Article null;
  19.     #[ORM\ManyToOne(inversedBy'articles')]
  20.     private ?User $User null;
  21.     #[ORM\OneToMany(mappedBy'article'targetEntityComments::class)]
  22.     private Collection $comments;
  23.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  24.     private ?\DateTimeInterface $date null;
  25.     public function __construct()
  26.     {
  27.         $this->comments = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getTitle(): ?string
  34.     {
  35.         return $this->Title;
  36.     }
  37.     public function setTitle(string $Title): self
  38.     {
  39.         $this->Title $Title;
  40.         return $this;
  41.     }
  42.     public function getArticle(): ?string
  43.     {
  44.         return $this->Article;
  45.     }
  46.     public function setArticle(string $Article): self
  47.     {
  48.         $this->Article $Article;
  49.         return $this;
  50.     }
  51.     public function getUser(): ?User
  52.     {
  53.         return $this->User;
  54.     }
  55.     public function setUser(?User $User): self
  56.     {
  57.         $this->User $User;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return Collection<int, Comments>
  62.      */
  63.     public function getComments(): Collection
  64.     {
  65.         return $this->comments;
  66.     }
  67.     public function addComment(Comments $comment): self
  68.     {
  69.         if (!$this->comments->contains($comment)) {
  70.             $this->comments->add($comment);
  71.             $comment->setArticle($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeComment(Comments $comment): self
  76.     {
  77.         if ($this->comments->removeElement($comment)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($comment->getArticle() === $this) {
  80.                 $comment->setArticle(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     public function getDate(): ?\DateTimeInterface
  86.     {
  87.         return $this->date;
  88.     }
  89.     public function setDate(\DateTimeInterface $date): self
  90.     {
  91.         $this->date $date;
  92.         return $this;
  93.     }
  94. }