src/Entity/Slave/ProductModel.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_model")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\ProductModelRepository")
  10.  */
  11. class ProductModel
  12. {      
  13.     public function __toString(){
  14.         return $this->getName().' ('.$this->getSku().')';
  15.     }
  16.     public function isPos(){
  17.         return $this->getSubcategory()->getCategory()->isPos();
  18.     }
  19.     
  20.     public function getDisplaySuppliers()
  21.     {
  22.         $result '';
  23.         $first true;
  24.         foreach($this->suppliers as $jt){
  25.             if($first$first false; else $result .= '<br>';
  26.             $result .= $jt->getSupplier()->getName();
  27.         }
  28.         return $result;
  29.     }
  30.     
  31.     public function getDisplayComponents()
  32.     {
  33.         $result '';
  34.         $first true;
  35.         foreach($this->components as $component){
  36.             if($first$first false; else $result .= '<br>';
  37.             $result .= $component->getName();
  38.         }
  39.         return $result;
  40.     }
  41.     public function getCanDelete(){
  42.         if(sizeof($this->products) > 0) return false;
  43.         return true;
  44.     }
  45.     /**
  46.      * @ORM\Column(name="id", type="bigint")
  47.      * @ORM\Id
  48.      * @ORM\GeneratedValue(strategy="AUTO")
  49.      */
  50.     protected $id;
  51.     
  52.     /**
  53.      * @ORM\Column(name="name", type="string", length=191)
  54.      */
  55.     protected $name;
  56.     
  57.     /**
  58.      * @ORM\Column(name="sku", type="string", length=191, nullable=true)
  59.      */
  60.     protected $sku;
  61.     
  62.     /**
  63.      * @ORM\Column(name="part_number", type="string", length=191, nullable=true)
  64.      */
  65.     protected $partNumber;
  66.     
  67.     /**
  68.      * @ORM\Column(name="internal_code", type="string", length=191, nullable=true)
  69.      */
  70.     protected $internalCode;
  71.         
  72.     /**
  73.      * @ORM\Column(name="image_path", type="string", length=191, nullable=true)
  74.      */
  75.     protected $imagePath;
  76.     
  77.     /**
  78.      * @ORM\Column(name="is_with_sim", type="boolean")
  79.      */
  80.     protected $withSim false;
  81.     
  82.     /**
  83.      * @ORM\Column(name="is_with_base", type="boolean")
  84.      */
  85.     protected $withBase false;
  86.     // ManyToOne
  87.         /**
  88.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\ProductSubcategory", inversedBy="models")
  89.          * @ORM\JoinColumn(name="subcategory_id", referencedColumnName="id")
  90.          */
  91.         private $subcategory;
  92.         /**
  93.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Producer", inversedBy="models")
  94.          * @ORM\JoinColumn(name="producer_id", referencedColumnName="id")
  95.          */
  96.         private $producer;
  97.     //
  98.     // OneToMany
  99.         /**
  100.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Product", mappedBy="model")
  101.          */
  102.         private $products;
  103.         /**
  104.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableProductModelSupplier", mappedBy="model")
  105.          */
  106.         private $suppliers;
  107.     //
  108.     
  109.     // ManyToMany
  110.         /**
  111.          * @ORM\ManyToMany(targetEntity="App\Entity\Slave\ProductComponent", inversedBy="models")
  112.          * @ORM\JoinTable(name="eposm_s_join_table_product_model_component")
  113.          */
  114.         private $components;
  115.         public function __construct()
  116.         {
  117.             $this->products = new ArrayCollection();
  118.             $this->suppliers = new ArrayCollection();
  119.             $this->components = new ArrayCollection();
  120.         }
  121.     //
  122.     public function getId(): ?string
  123.     {
  124.         return $this->id;
  125.     }
  126.     public function getName(): ?string
  127.     {
  128.         return $this->name;
  129.     }
  130.     public function setName(string $name): static
  131.     {
  132.         $this->name $name;
  133.         return $this;
  134.     }
  135.     public function getSku(): ?string
  136.     {
  137.         return $this->sku;
  138.     }
  139.     public function setSku(?string $sku): static
  140.     {
  141.         $this->sku $sku;
  142.         return $this;
  143.     }
  144.     public function getInternalCode(): ?string
  145.     {
  146.         return $this->internalCode;
  147.     }
  148.     public function setInternalCode(?string $internalCode): static
  149.     {
  150.         $this->internalCode $internalCode;
  151.         return $this;
  152.     }
  153.     public function getImagePath(): ?string
  154.     {
  155.         return $this->imagePath;
  156.     }
  157.     public function setImagePath(?string $imagePath): static
  158.     {
  159.         $this->imagePath $imagePath;
  160.         return $this;
  161.     }
  162.     public function isWithSim(): ?bool
  163.     {
  164.         return $this->withSim;
  165.     }
  166.     public function setWithSim(bool $withSim): static
  167.     {
  168.         $this->withSim $withSim;
  169.         return $this;
  170.     }
  171.     public function isWithBase(): ?bool
  172.     {
  173.         return $this->withBase;
  174.     }
  175.     public function setWithBase(bool $withBase): static
  176.     {
  177.         $this->withBase $withBase;
  178.         return $this;
  179.     }
  180.     public function getSubcategory(): ?ProductSubcategory
  181.     {
  182.         return $this->subcategory;
  183.     }
  184.     public function setSubcategory(?ProductSubcategory $subcategory): static
  185.     {
  186.         $this->subcategory $subcategory;
  187.         return $this;
  188.     }
  189.     public function getProducer(): ?Producer
  190.     {
  191.         return $this->producer;
  192.     }
  193.     public function setProducer(?Producer $producer): static
  194.     {
  195.         $this->producer $producer;
  196.         return $this;
  197.     }
  198.     /**
  199.      * @return Collection<int, Product>
  200.      */
  201.     public function getProducts(): Collection
  202.     {
  203.         return $this->products;
  204.     }
  205.     public function addProduct(Product $product): static
  206.     {
  207.         if (!$this->products->contains($product)) {
  208.             $this->products->add($product);
  209.             $product->setModel($this);
  210.         }
  211.         return $this;
  212.     }
  213.     public function removeProduct(Product $product): static
  214.     {
  215.         if ($this->products->removeElement($product)) {
  216.             // set the owning side to null (unless already changed)
  217.             if ($product->getModel() === $this) {
  218.                 $product->setModel(null);
  219.             }
  220.         }
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return Collection<int, JoinTableProductModelSupplier>
  225.      */
  226.     public function getSuppliers(): Collection
  227.     {
  228.         return $this->suppliers;
  229.     }
  230.     public function addSupplier(JoinTableProductModelSupplier $supplier): static
  231.     {
  232.         if (!$this->suppliers->contains($supplier)) {
  233.             $this->suppliers->add($supplier);
  234.             $supplier->setModel($this);
  235.         }
  236.         return $this;
  237.     }
  238.     public function removeSupplier(JoinTableProductModelSupplier $supplier): static
  239.     {
  240.         if ($this->suppliers->removeElement($supplier)) {
  241.             // set the owning side to null (unless already changed)
  242.             if ($supplier->getModel() === $this) {
  243.                 $supplier->setModel(null);
  244.             }
  245.         }
  246.         return $this;
  247.     }
  248.     /**
  249.      * @return Collection<int, ProductComponent>
  250.      */
  251.     public function getComponents(): Collection
  252.     {
  253.         return $this->components;
  254.     }
  255.     public function addComponent(ProductComponent $component): static
  256.     {
  257.         if (!$this->components->contains($component)) {
  258.             $this->components->add($component);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeComponent(ProductComponent $component): static
  263.     {
  264.         $this->components->removeElement($component);
  265.         return $this;
  266.     }
  267.     public function getPartNumber(): ?string
  268.     {
  269.         return $this->partNumber;
  270.     }
  271.     public function setPartNumber(?string $partNumber): static
  272.     {
  273.         $this->partNumber $partNumber;
  274.         return $this;
  275.     }
  276. }