src/Entity/Categories.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\SlugTrait;
  4. use App\Repository\CategoriesRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassCategoriesRepository::class)]
  9. class Categories
  10. {
  11.     use SlugTrait;
  12.     
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length100)]
  18.     private $name;
  19.     #[ORM\Column(type'integer')]
  20.     private $categoryOrder;
  21.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'categories')]
  22.     #[ORM\JoinColumn(onDelete'CASCADE')]
  23.     private $parent;
  24.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class)]
  25.     private $categories;
  26.     #[ORM\OneToMany(mappedBy'categories'targetEntityProducts::class)]
  27.     private $products;
  28.     #[ORM\ManyToOne(inversedBy'categories')]
  29.     private ?Asks $asks null;
  30.     #[ORM\OneToMany(mappedBy'answer1'targetEntityProducts::class)]
  31.     private Collection $productsAnswser1;
  32.     #[ORM\OneToMany(mappedBy'answer2'targetEntityProducts::class)]
  33.     private Collection $productsAnswer2;
  34.     #[ORM\OneToMany(mappedBy'answer3'targetEntityProducts::class)]
  35.     private Collection $productsAnswer3;
  36.     #[ORM\OneToMany(mappedBy'answer4'targetEntityProducts::class)]
  37.     private Collection $productsAnswer4;
  38.     #[ORM\OneToMany(mappedBy'answer5'targetEntityProducts::class)]
  39.     private Collection $productsAnswer5;
  40.     #[ORM\OneToMany(mappedBy'answer6'targetEntityProducts::class)]
  41.     private Collection $productsAnswer6;
  42.     public function __construct()
  43.     {
  44.         $this->categories = new ArrayCollection();
  45.         $this->products = new ArrayCollection();
  46.         $this->productsAnswser1 = new ArrayCollection();
  47.         $this->productsAnswer2 = new ArrayCollection();
  48.         $this->productsAnswer3 = new ArrayCollection();
  49.         $this->productsAnswer4 = new ArrayCollection();
  50.         $this->productsAnswer5 = new ArrayCollection();
  51.         $this->productsAnswer6 = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(string $name): self
  62.     {
  63.         $this->name $name;
  64.         return $this;
  65.     }
  66.     public function getCategoryOrder(): ?int
  67.     {
  68.         return $this->categoryOrder;
  69.     }
  70.     public function setCategoryOrder(int $categoryOrder): self
  71.     {
  72.         $this->categoryOrder $categoryOrder;
  73.         return $this;
  74.     }
  75.     public function getParent(): ?self
  76.     {
  77.         return $this->parent;
  78.     }
  79.     public function setParent(?self $parent): self
  80.     {
  81.         $this->parent $parent;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection|self[]
  86.      */
  87.     public function getCategories(): Collection
  88.     {
  89.         return $this->categories;
  90.     }
  91.     public function addCategory(self $category): self
  92.     {
  93.         if (!$this->categories->contains($category)) {
  94.             $this->categories[] = $category;
  95.             $category->setParent($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeCategory(self $category): self
  100.     {
  101.         if ($this->categories->removeElement($category)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($category->getParent() === $this) {
  104.                 $category->setParent(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection|Products[]
  111.      */
  112.     public function getProducts(): Collection
  113.     {
  114.         return $this->products;
  115.     }
  116.     public function addProduct(Products $product): self
  117.     {
  118.         if (!$this->products->contains($product)) {
  119.             $this->products[] = $product;
  120.             $product->setCategories($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeProduct(Products $product): self
  125.     {
  126.         if ($this->products->removeElement($product)) {
  127.             // set the owning side to null (unless already changed)
  128.             if ($product->getCategories() === $this) {
  129.                 $product->setCategories(null);
  130.             }
  131.         }
  132.         return $this;
  133.     }
  134.     public function getAsks(): ?Asks
  135.     {
  136.         return $this->asks;
  137.     }
  138.     public function setAsks(?Asks $asks): static
  139.     {
  140.         $this->asks $asks;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Collection<int, Products>
  145.      */
  146.     public function getProductsAnswser1(): Collection
  147.     {
  148.         return $this->productsAnswser1;
  149.     }
  150.     public function addProductsAnswser1(Products $productsAnswser1): static
  151.     {
  152.         if (!$this->productsAnswser1->contains($productsAnswser1)) {
  153.             $this->productsAnswser1->add($productsAnswser1);
  154.             $productsAnswser1->setAnswer1($this);
  155.         }
  156.         return $this;
  157.     }
  158.     public function removeProductsAnswser1(Products $productsAnswser1): static
  159.     {
  160.         if ($this->productsAnswser1->removeElement($productsAnswser1)) {
  161.             // set the owning side to null (unless already changed)
  162.             if ($productsAnswser1->getAnswer1() === $this) {
  163.                 $productsAnswser1->setAnswer1(null);
  164.             }
  165.         }
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return Collection<int, Products>
  170.      */
  171.     public function getProductsAnswer2(): Collection
  172.     {
  173.         return $this->productsAnswer2;
  174.     }
  175.     public function addProductsAnswer2(Products $productsAnswer2): static
  176.     {
  177.         if (!$this->productsAnswer2->contains($productsAnswer2)) {
  178.             $this->productsAnswer2->add($productsAnswer2);
  179.             $productsAnswer2->setAnswer2($this);
  180.         }
  181.         return $this;
  182.     }
  183.     public function removeProductsAnswer2(Products $productsAnswer2): static
  184.     {
  185.         if ($this->productsAnswer2->removeElement($productsAnswer2)) {
  186.             // set the owning side to null (unless already changed)
  187.             if ($productsAnswer2->getAnswer2() === $this) {
  188.                 $productsAnswer2->setAnswer2(null);
  189.             }
  190.         }
  191.         return $this;
  192.     }
  193.     /**
  194.      * @return Collection<int, Products>
  195.      */
  196.     public function getProductsAnswer3(): Collection
  197.     {
  198.         return $this->productsAnswer3;
  199.     }
  200.     public function addProductsAnswer3(Products $productsAnswer3): static
  201.     {
  202.         if (!$this->productsAnswer3->contains($productsAnswer3)) {
  203.             $this->productsAnswer3->add($productsAnswer3);
  204.             $productsAnswer3->setAnswer3($this);
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeProductsAnswer3(Products $productsAnswer3): static
  209.     {
  210.         if ($this->productsAnswer3->removeElement($productsAnswer3)) {
  211.             // set the owning side to null (unless already changed)
  212.             if ($productsAnswer3->getAnswer3() === $this) {
  213.                 $productsAnswer3->setAnswer3(null);
  214.             }
  215.         }
  216.         return $this;
  217.     }
  218.     /**
  219.      * @return Collection<int, Products>
  220.      */
  221.     public function getProductsAnswer4(): Collection
  222.     {
  223.         return $this->productsAnswer4;
  224.     }
  225.     public function addProductsAnswer4(Products $productsAnswer4): static
  226.     {
  227.         if (!$this->productsAnswer4->contains($productsAnswer4)) {
  228.             $this->productsAnswer4->add($productsAnswer4);
  229.             $productsAnswer4->setAnswer4($this);
  230.         }
  231.         return $this;
  232.     }
  233.     public function removeProductsAnswer4(Products $productsAnswer4): static
  234.     {
  235.         if ($this->productsAnswer4->removeElement($productsAnswer4)) {
  236.             // set the owning side to null (unless already changed)
  237.             if ($productsAnswer4->getAnswer4() === $this) {
  238.                 $productsAnswer4->setAnswer4(null);
  239.             }
  240.         }
  241.         return $this;
  242.     }
  243.     /**
  244.      * @return Collection<int, Products>
  245.      */
  246.     public function getProductsAnswer5(): Collection
  247.     {
  248.         return $this->productsAnswer5;
  249.     }
  250.     public function addProductsAnswer5(Products $productsAnswer5): static
  251.     {
  252.         if (!$this->productsAnswer5->contains($productsAnswer5)) {
  253.             $this->productsAnswer5->add($productsAnswer5);
  254.             $productsAnswer5->setAnswer5($this);
  255.         }
  256.         return $this;
  257.     }
  258.     public function removeProductsAnswer5(Products $productsAnswer5): static
  259.     {
  260.         if ($this->productsAnswer5->removeElement($productsAnswer5)) {
  261.             // set the owning side to null (unless already changed)
  262.             if ($productsAnswer5->getAnswer5() === $this) {
  263.                 $productsAnswer5->setAnswer5(null);
  264.             }
  265.         }
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return Collection<int, Products>
  270.      */
  271.     public function getProductsAnswer6(): Collection
  272.     {
  273.         return $this->productsAnswer6;
  274.     }
  275.     public function addProductsAnswer6(Products $productsAnswer6): static
  276.     {
  277.         if (!$this->productsAnswer6->contains($productsAnswer6)) {
  278.             $this->productsAnswer6->add($productsAnswer6);
  279.             $productsAnswer6->setAnswer6($this);
  280.         }
  281.         return $this;
  282.     }
  283.     public function removeProductsAnswer6(Products $productsAnswer6): static
  284.     {
  285.         if ($this->productsAnswer6->removeElement($productsAnswer6)) {
  286.             // set the owning side to null (unless already changed)
  287.             if ($productsAnswer6->getAnswer6() === $this) {
  288.                 $productsAnswer6->setAnswer6(null);
  289.             }
  290.         }
  291.         return $this;
  292.     }
  293. }