src/Entity/Slave/ProductCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_product_category")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\ProductCategoryRepository")
  10.  */
  11. class ProductCategory
  12. {        
  13.     public function __toString(){
  14.         return $this->getName();
  15.     }
  16.     
  17.     public function getCanDelete(){
  18.         if(sizeof($this->subcategories) > 0) return false;
  19.         return true;
  20.     }
  21.     /**
  22.      * @ORM\Column(name="id", type="bigint")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     protected $id;
  27.     
  28.     /**
  29.      * @ORM\Column(name="name", type="string", length=191)
  30.      */
  31.     protected $name;
  32.         
  33.     /**
  34.      * @ORM\Column(name="is_pos", type="boolean")
  35.      */
  36.     protected $pos true;
  37.     // OneToMany
  38.         /**
  39.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductSubcategory", mappedBy="category")
  40.          */
  41.         private $subcategories;
  42.         public function __construct()
  43.         {
  44.             $this->subcategories = new ArrayCollection();
  45.         }
  46.     //
  47.     public function getId(): ?string
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     public function isPos(): ?bool
  61.     {
  62.         return $this->pos;
  63.     }
  64.     public function setPos(bool $pos): self
  65.     {
  66.         $this->pos $pos;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection<int, ProductSubcategory>
  71.      */
  72.     public function getSubcategories(): Collection
  73.     {
  74.         return $this->subcategories;
  75.     }
  76.     public function addSubcategory(ProductSubcategory $subcategory): self
  77.     {
  78.         if (!$this->subcategories->contains($subcategory)) {
  79.             $this->subcategories->add($subcategory);
  80.             $subcategory->setCategory($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeSubcategory(ProductSubcategory $subcategory): self
  85.     {
  86.         if ($this->subcategories->removeElement($subcategory)) {
  87.             // set the owning side to null (unless already changed)
  88.             if ($subcategory->getCategory() === $this) {
  89.                 $subcategory->setCategory(null);
  90.             }
  91.         }
  92.         return $this;
  93.     }
  94. }