vendor/fri0z/mldev-catalog-bundle/src/Entity/ProductItemPrice.php line 12

Open in your IDE?
  1. <?php
  2. namespace MLDev\CatalogBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use JsonSerializable;
  5. /**
  6.  * @ORM\Table(name="MLDev_Product_Item_Price")
  7.  * @ORM\Entity()
  8.  */
  9. class ProductItemPrice implements JsonSerializable
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\ManyToOne(targetEntity=Price::class)
  14.      * @ORM\JoinColumn(name="price_id", referencedColumnName="id", onDelete="CASCADE")
  15.      */
  16.     private $price;
  17.     /**
  18.      * @ORM\Id()
  19.      * @ORM\ManyToOne(targetEntity=ProductItem::class, inversedBy="prices")
  20.      * @ORM\JoinColumn(name="product_item_id", referencedColumnName="id", onDelete="CASCADE")
  21.      */
  22.     private $productItem;
  23.     /**
  24.      * @ORM\Column(type="float", name="value", nullable=true)
  25.      */
  26.     private $value;
  27.     /**
  28.      * @ORM\Column(type="float", name="old_value", nullable=true)
  29.      */
  30.     private $oldValue;
  31.     /**
  32.      * ProductItemPrice constructor.
  33.      */
  34.     public function __construct(?Price $price, ?ProductItem $productItem, ?float $value null, ?float $oldValue null)
  35.     {
  36.         $this->price $price;
  37.         $this->productItem $productItem;
  38.         $this->value $value;
  39.         $this->oldValue $oldValue;
  40.     }
  41.     public function getPrice(): ?Price
  42.     {
  43.         return $this->price;
  44.     }
  45.     public function setPrice(?Price $price): void
  46.     {
  47.         $this->price $price;
  48.     }
  49.     public function getProductItem(): ?ProductItem
  50.     {
  51.         return $this->productItem;
  52.     }
  53.     public function setProductItem(?ProductItem $productItem): void
  54.     {
  55.         $this->productItem $productItem;
  56.     }
  57.     public function getValue(): ?float
  58.     {
  59.         return $this->value;
  60.     }
  61.     public function setValue(?float $value): void
  62.     {
  63.         $this->value $value;
  64.     }
  65.     public function getOldValue(): ?float
  66.     {
  67.         return $this->oldValue;
  68.     }
  69.     public function setOldValue(?float $oldValue): void
  70.     {
  71.         $this->oldValue $oldValue;
  72.     }
  73.     public function getPriceAlias(): ?string
  74.     {
  75.         return $this->getPrice() ? $this->getPrice()->getAlias() : null;
  76.     }
  77.     public function getPriceBasic(): ?bool
  78.     {
  79.         return $this->getPrice() ? $this->getPrice()->getBasic() : null;
  80.     }
  81.     public function jsonSerialize(): array
  82.     {
  83.         return [
  84.             'priceId' => $this->getPrice()->getId(),
  85.             'productItem' => $this->getProductItem()->getId(),
  86.             'value' => $this->getValue(),
  87.             'oldValue' => $this->getOldValue(),
  88.         ];
  89.     }
  90. }