<?php
namespace App\Entity;
use App\Repository\ProductOemRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation as Serializer;
use Symfony\Component\Serializer\Annotation\SerializedName;
use App\Annotation\DashboardAnnotation as Dashboard;
use App\Annotation\FormBuildAnnotation as FormBuild;
/**
* @ORM\Entity(repositoryClass=ProductOemRepository::class)
* @Dashboard(generation=true, name="OEM-номер")
* @ORM\Table(indexes={
* @ORM\Index(name="product_oem_trim_idx", columns={"oem_Trim"})
* })
*/
class ProductOem
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Serializer\Groups({"collection", "selection/data", "selection/id"})
* @Dashboard(label="Номер", only=true)
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Groups({"collection", "selection/data", "selection/id"})
* @SerializedName("oem")
* @Dashboard(label="OEM-номер")
* @FormBuild(component="input")
*/
private $oem;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Groups({"collection"})
* @Dashboard(label="Поиск по OEM")
* @FormBuild(component="input")
*/
private $oemTrim;
/**
* @ORM\ManyToOne(targetEntity=ProductArticle::class, inversedBy="productOems")
* @Dashboard(label="Артикул")
* @ORM\JoinColumn(nullable=true)
* @FormBuild(component="autocomplete", bindField="productArticle", field="title", params={"nullable": true})
*/
private $productArticle;
/**
* @ORM\ManyToOne(targetEntity=Product::class, inversedBy="productOems")
* @Serializer\Groups({"collection"})
* @Dashboard(label="Продукт")
* @ORM\JoinColumn(nullable=true)
* @FormBuild(component="autocomplete", description="Укажите продукцию, если артикул неизвестен.", bindField="product", field="title", params={"nullable": true})
*/
private $product;
/**
* @ORM\OneToMany(targetEntity=SelectionPart::class, mappedBy="productOem", cascade={"persist", "remove"}, orphanRemoval=true))
*/
private $selectionParts;
public function __construct()
{
$this->selectionParts = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getOem(): ?string
{
return $this->oem;
}
public function setOem(?string $oem): self
{
$this->oem = $oem;
return $this;
}
public function getOemTrim(): ?string
{
return $this->oemTrim;
}
public function setOemTrim(?string $oemTrim): self
{
$this->oemTrim = $oemTrim;
return $this;
}
public function getProductArticle(): ?ProductArticle
{
return $this->productArticle;
}
public function setProductArticle(?ProductArticle $productArticle): self
{
$this->productArticle = $productArticle;
return $this;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): self
{
$this->product = $product;
return $this;
}
/**
* @return Collection<int, SelectionPart>
*/
public function getSelectionParts(): Collection
{
return $this->selectionParts;
}
public function addSelectionParts(SelectionPart $selectionPart): self
{
if (!$this->selectionParts->contains($selectionPart)) {
$this->selectionParts[] = $selectionPart;
$selectionPart->setProductArticle($this);
}
return $this;
}
public function removeSelectionParts(SelectionPart $selectionPart): self
{
if ($this->selectionParts->removeElement($selectionPart)) {
// set the owning side to null (unless already changed)
if ($selectionPart->getProductArticle() === $this) {
$selectionPart->setProductArticle(null);
}
}
return $this;
}
}