src/Entity/Slave/ProductComponent.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_component")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\ProductComponentRepository")
  10.  */
  11. class ProductComponent
  12. {       
  13.     public function __toString(){
  14.         return $this->getName();
  15.     }
  16.     
  17.     public function getCanDelete(){
  18.         if(sizeof($this->models) > 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.     // ManyToMany
  33.         /**
  34.          * @ORM\ManyToMany(targetEntity="App\Entity\Slave\ProductModel", mappedBy="components")
  35.          */
  36.         private $models;
  37.         public function __construct()
  38.         {
  39.             $this->models = new ArrayCollection();
  40.         }
  41.     //
  42.     public function getId(): ?string
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getName(): ?string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function setName(string $name): self
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection<int, ProductModel>
  57.      */
  58.     public function getModels(): Collection
  59.     {
  60.         return $this->models;
  61.     }
  62.     public function addModel(ProductModel $model): self
  63.     {
  64.         if (!$this->models->contains($model)) {
  65.             $this->models->add($model);
  66.             $model->addComponent($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeModel(ProductModel $model): self
  71.     {
  72.         if ($this->models->removeElement($model)) {
  73.             $model->removeComponent($this);
  74.         }
  75.         return $this;
  76.     }
  77. }