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