src/Entity/Category.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CategoryRepository::class)
  9.  */
  10. class Category
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=true)
  24.      */
  25.     private $color;
  26.     /**
  27.      * @ORM\ManyToMany(targetEntity=Project::class, mappedBy="category")
  28.      */
  29.     private $projects;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $slug;
  34.     /**
  35.      * @ORM\Column(type="boolean")
  36.      */
  37.     private $isMenu true;
  38.     public function __construct()
  39.     {
  40.         $this->projects = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     /**
  47.      * @param mixed $id
  48.      */
  49.     public function setId($id): void
  50.     {
  51.         $this->id $id;
  52.     }
  53.     public function getName(): ?string
  54.     {
  55.         return $this->name;
  56.     }
  57.     public function setName(string $name): self
  58.     {
  59.         $this->name $name;
  60.         return $this;
  61.     }
  62.     public function getColor(): ?string
  63.     {
  64.         return $this->color;
  65.     }
  66.     public function setColor(?string $color): self
  67.     {
  68.         $this->color $color;
  69.         return $this;
  70.     }
  71.     /**
  72.      * @return Collection|Project[]
  73.      */
  74.     public function getProjects(): Collection
  75.     {
  76.         return $this->projects;
  77.     }
  78.     /**
  79.      * @param ArrayCollection $projects
  80.      */
  81.     public function setProjects(ArrayCollection $projects): void
  82.     {
  83.         $this->projects $projects;
  84.     }
  85.     public function addProject(Project $project): self
  86.     {
  87.         if (!$this->projects->contains($project)) {
  88.             $this->projects[] = $project;
  89.             $project->addCategory($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeProject(Project $project): self
  94.     {
  95.         if ($this->projects->removeElement($project)) {
  96.             $project->removeCategory($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function getSlug(): ?string
  101.     {
  102.         return $this->slug;
  103.     }
  104.     public function setSlug(?string $slug): self
  105.     {
  106.         $this->slug $slug;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return bool
  111.      */
  112.     public function isMenu(): ?bool
  113.     {
  114.         return $this->isMenu;
  115.     }
  116.     /**
  117.      * @param bool $isMenu
  118.      */
  119.     public function setIsMenu(bool $isMenu): void
  120.     {
  121.         $this->isMenu $isMenu;
  122.     }
  123.     public function getIsMenu(): ?bool
  124.     {
  125.         return $this->isMenu;
  126.     }
  127. }