<?phpnamespace App\Entity;use App\Repository\SubCategoryRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=SubCategoryRepository::class) */class SubCategory{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=255) */ private $label; /** * @ORM\Column(type="string", length=10, nullable=true) */ private $code; /** * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="subCategories") * @ORM\JoinColumn(nullable=false) */ private $category; /** * @ORM\Column(type="datetime") */ private $creation_date; /** * @ORM\OneToMany(targetEntity=Product::class, mappedBy="subCategory") */ private $products; public function __construct() { $this->products = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): self { $this->label = $label; return $this; } public function getCode(): ?string { return $this->code; } public function setCode(?string $code): self { $this->code = $code; return $this; } public function getCategory(): ?Category { return $this->category; } public function setCategory(?Category $category): self { $this->category = $category; return $this; } public function getCreationDate(): ?\DateTimeInterface { return $this->creation_date; } public function setCreationDate(\DateTimeInterface $creation_date): self { $this->creation_date = $creation_date; return $this; } /** * @return Collection<int, Product> */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products[] = $product; $product->setSubCategory($this); } return $this; } public function removeProduct(Product $product): self { if ($this->products->removeElement($product)) { // set the owning side to null (unless already changed) if ($product->getSubCategory() === $this) { $product->setSubCategory(null); } } return $this; }}