src/Entity/CategoryMaster.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryMasterRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CategoryMasterRepository::class)
  9.  */
  10. class CategoryMaster
  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)
  24.      */
  25.     private $slugName;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $image;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=Category::class, mappedBy="categoryMaster")
  32.      */
  33.     private $categories;
  34.     public function __construct()
  35.     {
  36.         $this->categories = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     public function getSlugName(): ?string
  52.     {
  53.         return $this->slugName;
  54.     }
  55.     public function setSlugName(string $slugName): self
  56.     {
  57.         $this->slugName $slugName;
  58.         return $this;
  59.     }
  60.     public function getImage()
  61.     {
  62.         return $this->image;
  63.     }
  64.     public function setImage($image)
  65.     {
  66.         $this->image $image;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection|Category[]
  71.      */
  72.     public function getCategories(): Collection
  73.     {
  74.         return $this->categories;
  75.     }
  76.     public function addCategory(Category $category): self
  77.     {
  78.         if (!$this->categories->contains($category)) {
  79.             $this->categories[] = $category;
  80.             $category->setCategoryMaster($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeCategory(Category $category): self
  85.     {
  86.         if ($this->categories->contains($category)) {
  87.             $this->categories->removeElement($category);
  88.             // set the owning side to null (unless already changed)
  89.             if ($category->getCategoryMaster() === $this) {
  90.                 $category->setCategoryMaster(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95. }