src/Entity/Category.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Symfony\Component\HttpFoundation\File\UploadedFile;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
  13.  *
  14.  */
  15. class Category
  16. {
  17.     /**
  18.     * @Gedmo\Slug(fields={"nom"})
  19.     * @ORM\Column(length=128, unique=true)
  20.     */
  21.     private $slug;
  22.     
  23.     /**
  24.      * @ORM\OneToMany(targetEntity="App\Entity\SubCategory", mappedBy="category", cascade={"persist", "remove"})
  25.      */
  26.     private $subCategories;
  27.     
  28.     /**
  29.      * @var int
  30.      *
  31.      * @ORM\Column(name="id", type="integer", nullable=false)
  32.      * @ORM\Id
  33.      * @ORM\GeneratedValue(strategy="IDENTITY")
  34.      */
  35.     private $id;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="name", type="string", length=255, nullable=true)
  40.      */
  41.     private $nom;
  42.     /**
  43.      * @var string|null
  44.      *
  45.      * @ORM\Column(name="icon", type="string", length=50, nullable=true)
  46.      */
  47.     private $icon;
  48.     /**
  49.      * @var string|null
  50.      *
  51.      * @ORM\Column(name="image_illustration", type="string", length=255, nullable=true)
  52.      */
  53.     private $imageIllustration;
  54.    public function __construct()
  55.    {
  56.        $this->subCategories = new ArrayCollection();
  57.    }
  58.    
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getNom(): ?string
  64.     {
  65.         return $this->nom;
  66.     }
  67.     public function setNom(?string $nom): self
  68.     {
  69.         $this->nom $nom;
  70.         return $this;
  71.     }
  72.     public function getSlug(): ?string
  73.        {
  74.            return $this->slug;
  75.        }
  76.     public function setSlug(?string $slug): self
  77.     {
  78.         $this->slug $slug;
  79.         return $this;
  80.     }
  81.     public function getIcon(): ?string
  82.        {
  83.            return $this->icon;
  84.        }
  85.     public function setIcon(?string $icon): self
  86.     {
  87.         $this->icon $icon;
  88.         return $this;
  89.     }
  90.     
  91.     public function getImageIllustration(): ?string
  92.        {
  93.            return $this->imageIllustration;
  94.        }
  95.     public function setImageIllustration(?string $imageIllustration): self
  96.     {
  97.         $this->imageIllustration $imageIllustration;
  98.         return $this;
  99.     }
  100.     
  101.     /**
  102.      * Add subCategories
  103.      *
  104.      * @param \App\Entity\SubCategory $subCategories
  105.      * @return Article
  106.      */
  107.     public function addSubCategory(\App\Entity\SubCategory $subCategory)
  108.     {
  109.         $subCategory->setCategory($this);
  110.         $this->subCategories[] = $subCategory;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Remove subCategories
  115.      *
  116.      * @param \App\Entity\SubCategory $subCategories
  117.      */
  118.     public function removeSubCategory(\App\Entity\SubCategory $subCategory)
  119.     {
  120.         $this->subCategories->removeElement($subCategory);
  121.     }
  122.     /**
  123.      * Get subCategories
  124.      *
  125.      * @return \Doctrine\Common\Collections\Collection 
  126.      */
  127.     public function getSubCategories()
  128.     {
  129.         return $this->subCategories;
  130.     }
  131. }