<?php
namespace App\Entity;
use App\Entity\Trait\SlugTrait;
use App\Repository\CategoriesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoriesRepository::class)]
class Categories
{
use SlugTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 100)]
private $name;
#[ORM\Column(type: 'integer')]
private $categoryOrder;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'categories')]
#[ORM\JoinColumn(onDelete: 'CASCADE')]
private $parent;
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private $categories;
#[ORM\OneToMany(mappedBy: 'categories', targetEntity: Products::class)]
private $products;
#[ORM\ManyToOne(inversedBy: 'categories')]
private ?Asks $asks = null;
#[ORM\OneToMany(mappedBy: 'answer1', targetEntity: Products::class)]
private Collection $productsAnswser1;
#[ORM\OneToMany(mappedBy: 'answer2', targetEntity: Products::class)]
private Collection $productsAnswer2;
#[ORM\OneToMany(mappedBy: 'answer3', targetEntity: Products::class)]
private Collection $productsAnswer3;
#[ORM\OneToMany(mappedBy: 'answer4', targetEntity: Products::class)]
private Collection $productsAnswer4;
#[ORM\OneToMany(mappedBy: 'answer5', targetEntity: Products::class)]
private Collection $productsAnswer5;
#[ORM\OneToMany(mappedBy: 'answer6', targetEntity: Products::class)]
private Collection $productsAnswer6;
public function __construct()
{
$this->categories = new ArrayCollection();
$this->products = new ArrayCollection();
$this->productsAnswser1 = new ArrayCollection();
$this->productsAnswer2 = new ArrayCollection();
$this->productsAnswer3 = new ArrayCollection();
$this->productsAnswer4 = new ArrayCollection();
$this->productsAnswer5 = new ArrayCollection();
$this->productsAnswer6 = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCategoryOrder(): ?int
{
return $this->categoryOrder;
}
public function setCategoryOrder(int $categoryOrder): self
{
$this->categoryOrder = $categoryOrder;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection|self[]
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(self $category): self
{
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
$category->setParent($this);
}
return $this;
}
public function removeCategory(self $category): self
{
if ($this->categories->removeElement($category)) {
// set the owning side to null (unless already changed)
if ($category->getParent() === $this) {
$category->setParent(null);
}
}
return $this;
}
/**
* @return Collection|Products[]
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Products $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setCategories($this);
}
return $this;
}
public function removeProduct(Products $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getCategories() === $this) {
$product->setCategories(null);
}
}
return $this;
}
public function getAsks(): ?Asks
{
return $this->asks;
}
public function setAsks(?Asks $asks): static
{
$this->asks = $asks;
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProductsAnswser1(): Collection
{
return $this->productsAnswser1;
}
public function addProductsAnswser1(Products $productsAnswser1): static
{
if (!$this->productsAnswser1->contains($productsAnswser1)) {
$this->productsAnswser1->add($productsAnswser1);
$productsAnswser1->setAnswer1($this);
}
return $this;
}
public function removeProductsAnswser1(Products $productsAnswser1): static
{
if ($this->productsAnswser1->removeElement($productsAnswser1)) {
// set the owning side to null (unless already changed)
if ($productsAnswser1->getAnswer1() === $this) {
$productsAnswser1->setAnswer1(null);
}
}
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProductsAnswer2(): Collection
{
return $this->productsAnswer2;
}
public function addProductsAnswer2(Products $productsAnswer2): static
{
if (!$this->productsAnswer2->contains($productsAnswer2)) {
$this->productsAnswer2->add($productsAnswer2);
$productsAnswer2->setAnswer2($this);
}
return $this;
}
public function removeProductsAnswer2(Products $productsAnswer2): static
{
if ($this->productsAnswer2->removeElement($productsAnswer2)) {
// set the owning side to null (unless already changed)
if ($productsAnswer2->getAnswer2() === $this) {
$productsAnswer2->setAnswer2(null);
}
}
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProductsAnswer3(): Collection
{
return $this->productsAnswer3;
}
public function addProductsAnswer3(Products $productsAnswer3): static
{
if (!$this->productsAnswer3->contains($productsAnswer3)) {
$this->productsAnswer3->add($productsAnswer3);
$productsAnswer3->setAnswer3($this);
}
return $this;
}
public function removeProductsAnswer3(Products $productsAnswer3): static
{
if ($this->productsAnswer3->removeElement($productsAnswer3)) {
// set the owning side to null (unless already changed)
if ($productsAnswer3->getAnswer3() === $this) {
$productsAnswer3->setAnswer3(null);
}
}
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProductsAnswer4(): Collection
{
return $this->productsAnswer4;
}
public function addProductsAnswer4(Products $productsAnswer4): static
{
if (!$this->productsAnswer4->contains($productsAnswer4)) {
$this->productsAnswer4->add($productsAnswer4);
$productsAnswer4->setAnswer4($this);
}
return $this;
}
public function removeProductsAnswer4(Products $productsAnswer4): static
{
if ($this->productsAnswer4->removeElement($productsAnswer4)) {
// set the owning side to null (unless already changed)
if ($productsAnswer4->getAnswer4() === $this) {
$productsAnswer4->setAnswer4(null);
}
}
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProductsAnswer5(): Collection
{
return $this->productsAnswer5;
}
public function addProductsAnswer5(Products $productsAnswer5): static
{
if (!$this->productsAnswer5->contains($productsAnswer5)) {
$this->productsAnswer5->add($productsAnswer5);
$productsAnswer5->setAnswer5($this);
}
return $this;
}
public function removeProductsAnswer5(Products $productsAnswer5): static
{
if ($this->productsAnswer5->removeElement($productsAnswer5)) {
// set the owning side to null (unless already changed)
if ($productsAnswer5->getAnswer5() === $this) {
$productsAnswer5->setAnswer5(null);
}
}
return $this;
}
/**
* @return Collection<int, Products>
*/
public function getProductsAnswer6(): Collection
{
return $this->productsAnswer6;
}
public function addProductsAnswer6(Products $productsAnswer6): static
{
if (!$this->productsAnswer6->contains($productsAnswer6)) {
$this->productsAnswer6->add($productsAnswer6);
$productsAnswer6->setAnswer6($this);
}
return $this;
}
public function removeProductsAnswer6(Products $productsAnswer6): static
{
if ($this->productsAnswer6->removeElement($productsAnswer6)) {
// set the owning side to null (unless already changed)
if ($productsAnswer6->getAnswer6() === $this) {
$productsAnswer6->setAnswer6(null);
}
}
return $this;
}
}