src/Entity/Articles.php line 15

  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. use phpDocumentor\Reflection\Types\Nullable;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassArticlesRepository::class)]
  12. class Articles
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $title null;
  20.     #[ORM\Column(length255)]
  21.     private ?string $catchPhrase null;
  22.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  23.     private ?\DateTimeInterface $date null;
  24.     #[ORM\Column(length255)]
  25.     private ?string $author null;
  26.     #[ORM\Column(typeTypes::TEXT)]
  27.     private ?string $description null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $picture null;
  30.     #[Assert\Image(
  31.         maxSize:"1024k"
  32.     )]
  33.     private $posterFile;
  34.     #[ORM\Column(nullable:true)]
  35.     private array $relatedSubjects = [];
  36.     #[ORM\Column(length255)]
  37.     private ?string $chapo null;
  38.     #[ORM\Column(length255)]
  39.     private ?string $legendMainPicture null;
  40.     #[ORM\Column(length255nullable:true)]
  41.     private ?string $authorWebsite null;
  42.     #[ORM\Column(nullable:true)]
  43.     private ?int $relatedCourse null;
  44.     #[ORM\ManyToOne(inversedBy:'articles')]
  45.     #[ORM\JoinColumn(nullablefalse)]
  46.     private ?Category $category null;
  47.     #[ORM\OneToMany(mappedBy'article'targetEntityComments::class)]
  48.     private Collection $comments;
  49.     public function __construct()
  50.     {
  51.         $this->comments = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getTitle(): ?string
  58.     {
  59.         return $this->title;
  60.     }
  61.     public function setTitle(string $title): self
  62.     {
  63.         $this->title $title;
  64.         return $this;
  65.     }
  66.     public function getPosterFile(): ?UploadedFile
  67.     {
  68.         return $this->posterFile;
  69.     }
  70.     public function setPosterFile(UploadedFile $posterFile): self
  71.     {
  72.         $this->posterFile $posterFile;
  73.         return $this;
  74.     }
  75.     public function getCatchPhrase(): ?string
  76.     {
  77.         return $this->catchPhrase;
  78.     }
  79.     public function setCatchPhrase(string $catchPhrase): self
  80.     {
  81.         $this->catchPhrase $catchPhrase;
  82.         return $this;
  83.     }
  84.     public function getDate(): ?\DateTimeInterface
  85.     {
  86.         return $this->date;
  87.     }
  88.     public function setDate(\DateTimeInterface $date): self
  89.     {
  90.         $this->date $date;
  91.         return $this;
  92.     }
  93.     public function getAuthor(): ?string
  94.     {
  95.         return $this->author;
  96.     }
  97.     public function setAuthor(string $author): self
  98.     {
  99.         $this->author $author;
  100.         return $this;
  101.     }
  102.     public function getDescription(): ?string
  103.     {
  104.         return $this->description;
  105.     }
  106.     public function setDescription(string $description): self
  107.     {
  108.         $this->description $description;
  109.         return $this;
  110.     }
  111.     public function getPicture(): ?string
  112.     {
  113.         return $this->picture;
  114.     }
  115.     public function setPicture(string $picture): self
  116.     {
  117.         $this->picture $picture;
  118.         return $this;
  119.     }
  120.     public function getRelatedSubjects(): array
  121.     {
  122.         return $this->relatedSubjects;
  123.     }
  124.     public function setRelatedSubjects(array $relatedSubjects): self
  125.     {
  126.         $this->relatedSubjects $relatedSubjects;
  127.         return $this;
  128.     }
  129.     public function getChapo(): ?string
  130.     {
  131.         return $this->chapo;
  132.     }
  133.     public function setChapo(string $chapo): self
  134.     {
  135.         $this->chapo $chapo;
  136.         return $this;
  137.     }
  138.     public function getLegendMainPicture(): ?string
  139.     {
  140.         return $this->legendMainPicture;
  141.     }
  142.     public function setLegendMainPicture(string $legendMainPicture): self
  143.     {
  144.         $this->legendMainPicture $legendMainPicture;
  145.         return $this;
  146.     }
  147.     public function getAuthorWebsite(): ?string
  148.     {
  149.         return $this->authorWebsite;
  150.     }
  151.     public function setAuthorWebsite(string $authorWebsite): self
  152.     {
  153.         $this->authorWebsite $authorWebsite;
  154.         return $this;
  155.     }
  156.     public function getRelatedCourse(): ?int
  157.     {
  158.         return $this->relatedCourse;
  159.     }
  160.     public function setRelatedCourse(int $relatedCourse): self
  161.     {
  162.         $this->relatedCourse $relatedCourse;
  163.         return $this;
  164.     }
  165.     public function getCategory(): ?Category
  166.     {
  167.         return $this->category;
  168.     }
  169.     public function setCategory(?Category $category): self
  170.     {
  171.         $this->category $category;
  172.         return $this;
  173.     }
  174.     /**
  175.      * @return Collection<int, Comments>
  176.      */
  177.     public function getComments(): Collection
  178.     {
  179.         return $this->comments;
  180.     }
  181.     public function addComment(Comments $comment): self
  182.     {
  183.         if (!$this->comments->contains($comment)) {
  184.             $this->comments->add($comment);
  185.             $comment->setArticle($this);
  186.         }
  187.         return $this;
  188.     }
  189.     public function removeComment(Comments $comment): self
  190.     {
  191.         if ($this->comments->removeElement($comment)) {
  192.             // set the owning side to null (unless already changed)
  193.             if ($comment->getArticle() === $this) {
  194.                 $comment->setArticle(null);
  195.             }
  196.         }
  197.         return $this;
  198.     }
  199. }