src/Entity/ProductOem.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductOemRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation as Serializer;
  8. use Symfony\Component\Serializer\Annotation\SerializedName;
  9. use App\Annotation\DashboardAnnotation as Dashboard;
  10. use App\Annotation\FormBuildAnnotation as FormBuild;
  11. /**
  12.  * @ORM\Entity(repositoryClass=ProductOemRepository::class)
  13.  * @Dashboard(generation=true, name="OEM-номер")
  14.  * @ORM\Table(indexes={
  15.  *     @ORM\Index(name="product_oem_trim_idx", columns={"oem_Trim"})
  16.  * })
  17.  */
  18. class ProductOem
  19. {
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      * @Serializer\Groups({"collection", "selection/data", "selection/id"})
  25.      * @Dashboard(label="Номер", only=true)
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      * @Serializer\Groups({"collection", "selection/data", "selection/id"})
  31.      * @SerializedName("oem") 
  32.      * @Dashboard(label="OEM-номер")
  33.      * @FormBuild(component="input")
  34.      */
  35.     private $oem;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      * @Serializer\Groups({"collection"}) 
  39.      * @Dashboard(label="Поиск по OEM")
  40.      * @FormBuild(component="input")
  41.      */
  42.     private $oemTrim;
  43.     /**
  44.      * @ORM\ManyToOne(targetEntity=ProductArticle::class, inversedBy="productOems")
  45.      * @Dashboard(label="Артикул")
  46.      * @ORM\JoinColumn(nullable=true)
  47.      * @FormBuild(component="autocomplete", bindField="productArticle", field="title",  params={"nullable": true})
  48.      */
  49.     private $productArticle;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=Product::class, inversedBy="productOems")
  52.      * @Serializer\Groups({"collection"}) 
  53.      * @Dashboard(label="Продукт")
  54.      * @ORM\JoinColumn(nullable=true)
  55.      * @FormBuild(component="autocomplete", description="Укажите продукцию, если артикул неизвестен.", bindField="product", field="title",  params={"nullable": true})
  56.      */
  57.     private $product;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=SelectionPart::class, mappedBy="productOem", cascade={"persist", "remove"}, orphanRemoval=true))
  60.      */
  61.     private $selectionParts;
  62.     public function __construct()
  63.     {
  64.         $this->selectionParts = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getOem(): ?string
  71.     {
  72.         return $this->oem;
  73.     }
  74.     public function setOem(?string $oem): self
  75.     {
  76.         $this->oem $oem;
  77.         return $this;
  78.     }
  79.     public function getOemTrim(): ?string
  80.     {
  81.         return $this->oemTrim;
  82.     }
  83.     public function setOemTrim(?string $oemTrim): self
  84.     {
  85.         $this->oemTrim $oemTrim;
  86.         return $this;
  87.     }
  88.     public function getProductArticle(): ?ProductArticle
  89.     {
  90.         return $this->productArticle;
  91.     }
  92.     public function setProductArticle(?ProductArticle $productArticle): self
  93.     {
  94.         $this->productArticle $productArticle;
  95.         return $this;
  96.     }
  97.     public function getProduct(): ?Product
  98.     {
  99.         return $this->product;
  100.     }
  101.     public function setProduct(?Product $product): self
  102.     {
  103.         $this->product $product;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, SelectionPart>
  108.      */
  109.     public function getSelectionParts(): Collection
  110.     {
  111.         return $this->selectionParts;
  112.     }
  113.     public function addSelectionParts(SelectionPart $selectionPart): self
  114.     {
  115.         if (!$this->selectionParts->contains($selectionPart)) {
  116.             $this->selectionParts[] = $selectionPart;
  117.             $selectionPart->setProductArticle($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeSelectionParts(SelectionPart $selectionPart): self
  122.     {
  123.         if ($this->selectionParts->removeElement($selectionPart)) {
  124.             // set the owning side to null (unless already changed)
  125.             if ($selectionPart->getProductArticle() === $this) {
  126.                 $selectionPart->setProductArticle(null);
  127.             }
  128.         }
  129.         return $this;
  130.     }
  131. }