<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use http\Env;
/**
* @ORM\Entity(repositoryClass=CategoryRepository::class)
*/
class Category
{
/**
* @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\Column(type="datetime")
*/
private $creation_date;
/**
* @ORM\OneToMany(targetEntity=SubCategory::class, mappedBy="category", orphanRemoval=true)
*/
private $subCategories;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="category", orphanRemoval=true)
*/
private $products;
/**
* @ORM\Column(type="string", length=255)
*/
private $target;
/**
* @ORM\Column(type="boolean")
*/
private $isSynch = true;
/**
* @ORM\Column(type="boolean")
*/
private $deleted = false;
public function __construct()
{
$this->subCategories = new ArrayCollection();
$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 getCreationDate(): ?\DateTimeInterface
{
return $this->creation_date;
}
public function setCreationDate(\DateTimeInterface $creation_date): self
{
$this->creation_date = $creation_date;
return $this;
}
/**
* @return Collection<int, SubCategory>
*/
public function getSubCategories(): Collection
{
return $this->subCategories;
}
public function addSubCategory(SubCategory $subCategory): self
{
if (!$this->subCategories->contains($subCategory)) {
$this->subCategories[] = $subCategory;
$subCategory->setCategory($this);
}
return $this;
}
public function removeSubCategory(SubCategory $subCategory): self
{
if ($this->subCategories->removeElement($subCategory)) {
// set the owning side to null (unless already changed)
if ($subCategory->getCategory() === $this) {
$subCategory->setCategory(null);
}
}
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->setCategory($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->getCategory() === $this) {
$product->setCategory(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getisSynch()
{
return $this->isSynch;
}
/**
* @param mixed $isSynch
*/
public function setisSynch($isSynch): void
{
$this->isSynch = $isSynch;
}
/**
* @return mixed
*/
public function getDeleted()
{
return $this->deleted;
}
/**
* @param mixed $deleted
*/
public function setDeleted($deleted): void
{
$this->deleted = $deleted;
}
/**
* @return mixed
*/
public function getTarget()
{
return $this->target;
}
/**
* @param mixed $target
*/
public function setTarget($target): void
{
$this->target = $target;
}
}