src/Entity/ArticlesCategories.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\ArticlesCategoriesRepository")
  8.  */
  9. class ArticlesCategories
  10. {
  11.     /**
  12.      * @ORM\Column(name="id", type="integer")
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue(strategy="AUTO")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  19.      */
  20.     private $name;
  21.     /**
  22.      * @ORM\Column(name="slug", type="string", length=255, nullable=true)
  23.      */
  24.     private $slug;
  25.     /**
  26.      * @ORM\Column(name="description", type="text", nullable=true)
  27.      */
  28.     private $description;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity="App\Entity\Picture",cascade={"persist"})
  31.      * @ORM\JoinColumn(nullable=true)
  32.      */
  33.     private $banner;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity="App\Entity\Articles", mappedBy="category")
  36.      */
  37.     private $articles;
  38.     /**
  39.      * @ORM\Column(name="isEnabled", type="boolean", nullable=true)
  40.      */
  41.     private $isEnabled;
  42.     public function __construct()
  43.     {
  44.         $this->articles = new ArrayCollection();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getName(): ?string
  51.     {
  52.         return $this->name;
  53.     }
  54.     public function setName(?string $name): self
  55.     {
  56.         $this->name $name;
  57.         return $this;
  58.     }
  59.     public function getSlug(): ?string
  60.     {
  61.         return $this->slug;
  62.     }
  63.     public function setSlug(?string $slug): self
  64.     {
  65.         $this->slug $slug;
  66.         return $this;
  67.     }
  68.     public function getDescription(): ?string
  69.     {
  70.         return $this->description;
  71.     }
  72.     public function setDescription(?string $description): self
  73.     {
  74.         $this->description $description;
  75.         return $this;
  76.     }
  77.     public function getBanner(): ?Picture
  78.     {
  79.         return $this->banner;
  80.     }
  81.     public function setBanner(?Picture $banner): self
  82.     {
  83.         $banner->setDir('articles');
  84.         $this->banner $banner;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return Collection|Articles[]
  89.      */
  90.     public function getArticles(): ?Collection
  91.     {
  92.         return $this->articles;
  93.     }
  94.     public function addArticle(Articles $article): self
  95.     {
  96.         if (!$this->articles->contains($article)) {
  97.             $this->articles[] = $article;
  98.             $article->setCategory($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeArticle(Articles $article): self
  103.     {
  104.         if ($this->articles->contains($article)) {
  105.             $this->articles->removeElement($article);
  106.             // set the owning side to null (unless already changed)
  107.             if ($article->getCategory() === $this) {
  108.                 $article->setCategory(null);
  109.             }
  110.         }
  111.         return $this;
  112.     }
  113.     public function getIsEnabled(): ?bool
  114.     {
  115.         return $this->isEnabled;
  116.     }
  117.     public function setIsEnabled(?bool $isEnabled): self
  118.     {
  119.         $this->isEnabled $isEnabled;
  120.         return $this;
  121.     }
  122. }