<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_product_category")
* @ORM\Entity(repositoryClass="App\Repository\Slave\ProductCategoryRepository")
*/
class ProductCategory
{
public function __toString(){
return $this->getName();
}
public function getCanDelete(){
if(sizeof($this->subcategories) > 0) return false;
return true;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name", type="string", length=191)
*/
protected $name;
/**
* @ORM\Column(name="is_pos", type="boolean")
*/
protected $pos = true;
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductSubcategory", mappedBy="category")
*/
private $subcategories;
public function __construct()
{
$this->subcategories = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function isPos(): ?bool
{
return $this->pos;
}
public function setPos(bool $pos): self
{
$this->pos = $pos;
return $this;
}
/**
* @return Collection<int, ProductSubcategory>
*/
public function getSubcategories(): Collection
{
return $this->subcategories;
}
public function addSubcategory(ProductSubcategory $subcategory): self
{
if (!$this->subcategories->contains($subcategory)) {
$this->subcategories->add($subcategory);
$subcategory->setCategory($this);
}
return $this;
}
public function removeSubcategory(ProductSubcategory $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;
}
}