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.         public function getId(): ?string
  47.         {
  48.             return $this->id;
  49.         }
  50.         public function getName(): ?string
  51.         {
  52.             return $this->name;
  53.         }
  54.         public function setName(string $name): static
  55.         {
  56.             $this->name $name;
  57.             return $this;
  58.         }
  59.         public function isPos(): ?bool
  60.         {
  61.             return $this->pos;
  62.         }
  63.         public function setPos(bool $pos): static
  64.         {
  65.             $this->pos $pos;
  66.             return $this;
  67.         }
  68.         /**
  69.          * @return Collection<int, ProductSubcategory>
  70.          */
  71.         public function getSubcategories(): Collection
  72.         {
  73.             return $this->subcategories;
  74.         }
  75.         public function addSubcategory(ProductSubcategory $subcategory): static
  76.         {
  77.             if (!$this->subcategories->contains($subcategory)) {
  78.                 $this->subcategories->add($subcategory);
  79.                 $subcategory->setCategory($this);
  80.             }
  81.             return $this;
  82.         }
  83.         public function removeSubcategory(ProductSubcategory $subcategory): static
  84.         {
  85.             if ($this->subcategories->removeElement($subcategory)) {
  86.                 // set the owning side to null (unless already changed)
  87.                 if ($subcategory->getCategory() === $this) {
  88.                     $subcategory->setCategory(null);
  89.                 }
  90.             }
  91.             return $this;
  92.         }
  93. }