vendor/fri0z/mldev-catalog-bundle/src/Entity/ProductItemStock.php line 11

Open in your IDE?
  1. <?php
  2. namespace MLDev\CatalogBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Table(name="MLDev_Product_Item_Stock")
  6.  * @ORM\Entity()
  7.  */
  8. class ProductItemStock implements \JsonSerializable
  9. {
  10.     /**
  11.      * @ORM\Id()
  12.      * @ORM\ManyToOne(targetEntity=Stock::class)
  13.      * @ORM\JoinColumn(name="stock_id", referencedColumnName="id", onDelete="CASCADE")
  14.      */
  15.     private $stock;
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\ManyToOne(targetEntity=ProductItem::class, inversedBy="stocks")
  19.      * @ORM\JoinColumn(name="product_item_id", referencedColumnName="id", onDelete="CASCADE")
  20.      */
  21.     private $productItem;
  22.     /**
  23.      * @ORM\Column(type="integer", name="value", nullable=true)
  24.      */
  25.     private $value 0;
  26.     /**
  27.      * ProductItemStock constructor.
  28.      */
  29.     public function __construct(?Stock $stock, ?ProductItem $productItem, ?int $value 0)
  30.     {
  31.         $this->stock $stock;
  32.         $this->productItem $productItem;
  33.         $this->value $value;
  34.     }
  35.     public function getStock(): ?Stock
  36.     {
  37.         return $this->stock;
  38.     }
  39.     public function setStock(?Stock $stock): void
  40.     {
  41.         $this->stock $stock;
  42.     }
  43.     public function getProductItem(): ?ProductItem
  44.     {
  45.         return $this->productItem;
  46.     }
  47.     public function setProductItem(?ProductItem $productItem): void
  48.     {
  49.         $this->productItem $productItem;
  50.     }
  51.     public function getValue(): ?int
  52.     {
  53.         return $this->value;
  54.     }
  55.     public function setValue(?int $value): void
  56.     {
  57.         $this->value $value;
  58.     }
  59.     public function isBasicStock(): bool
  60.     {
  61.         return $this->getStock() ? $this->getStock()->getBasic() : false;
  62.     }
  63.     public function jsonSerialize(): array
  64.     {
  65.         return [
  66.             'stockId' => $this->getStock()->getId(),
  67.             'productItem' => $this->getProductItem()->getId(),
  68.             'value' => $this->getValue(),
  69.         ];
  70.     }
  71. }