<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductOptionValueRepository")
*/
class ProductOptionValue
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="bigint")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $value;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ProductOption", inversedBy="productOptionValues")
* @ORM\JoinColumn(name="product_option_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $productOption;
/**
* @ORM\Column(type="integer")
*/
private $price;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\PurchaseItem", mappedBy="product_option_values")
*/
private $purchase_items;
public function __construct ()
{
$this->value = "";
$this->amount = 0;
$this->purchase_items = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value = null): self
{
$this->value = $value ? $value : "";
return $this;
}
public function getProductOption(): ?ProductOption
{
return $this->productOption;
}
public function setProductOption(?ProductOption $productOption = null): self
{
$this->productOption = $productOption;
return $this;
}
public function getPrice()
{
return $this->price;
}
public function setPrice($price = 0)
{
$this->price = $price;
return $this;
}
public function getPurchaseItems (): Collection
{
return $this->purchase_items;
}
public function addPurchaseItem (PurchaseItem $purchase_item)
{
if (!$this->purchase_items->contains($purchase_item)) {
$this->purchase_items[] = $purchase_item;
$purchase_item->addProductOptionValue($this);
}
return $this;
}
public function removePurchaseItem (PurchaseItem $purchase_item): self
{
if ($this->purchase_items->contains($purchase_item)) {
$this->purchase_items->removeElement($purchase_item);
$purchase_item->removeProductOptionValue($this);
}
return $this;
}
public function __toString ()
{
return $this->value ? $this->value : '';
}
}