src/Entity/ArticlesCategories.php line 12

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