src/Entity/Shop/Product/ProductPrice.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Product;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Order\OrderItem;
  5. use App\Repository\Shop\Product\ProductPriceRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  11. #[ORM\Entity(repositoryClassProductPriceRepository::class)]
  12. class ProductPrice extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\Column(type'guid'uniquetrue)]
  16.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  17.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  18.     private ?string $id;
  19.     #[ORM\Column(nullabletrue)]
  20.     private ?int $inStock null;
  21.     #[ORM\Column(typeTypes::BIGINT)]
  22.     private ?string $price null;
  23.     #[ORM\ManyToMany(targetEntityProductAttributeValue::class, inversedBy'productPrices')]
  24.     private Collection $selectedValues;
  25.     #[ORM\ManyToOne(inversedBy'productPrices')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private ?Product $product null;
  28.     #[ORM\OneToMany(mappedBy'productPrice'targetEntityOrderItem::class)]
  29.     private Collection $orderItems;
  30.     public function __construct()
  31.     {
  32.         parent::__construct();
  33.         $this->selectedValues = new ArrayCollection();
  34.         $this->orderItems = new ArrayCollection();
  35.     }
  36.     public function getId(): ?string
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getInStock(): ?int
  41.     {
  42.         return $this->inStock;
  43.     }
  44.     public function setInStock(?int $inStock): static
  45.     {
  46.         $this->inStock $inStock;
  47.         return $this;
  48.     }
  49.     public function getPrice(): ?string
  50.     {
  51.         return $this->price;
  52.     }
  53.     public function setPrice(string $price): static
  54.     {
  55.         $this->price $price;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return Collection<int, ProductAttributeValue>
  60.      */
  61.     public function getSelectedValues(): Collection
  62.     {
  63.         return $this->selectedValues;
  64.     }
  65.     public function addSelectedValue(ProductAttributeValue $selectedValue): static
  66.     {
  67.         if (!$this->selectedValues->contains($selectedValue)) {
  68.             $this->selectedValues->add($selectedValue);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeSelectedValue(ProductAttributeValue $selectedValue): static
  73.     {
  74.         $this->selectedValues->removeElement($selectedValue);
  75.         return $this;
  76.     }
  77.     public function getProduct(): ?Product
  78.     {
  79.         return $this->product;
  80.     }
  81.     public function setProduct(?Product $product): static
  82.     {
  83.         $this->product $product;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return Collection<int, OrderItem>
  88.      */
  89.     public function getOrderItems(): Collection
  90.     {
  91.         return $this->orderItems;
  92.     }
  93.     public function addOrderItem(OrderItem $orderItem): static
  94.     {
  95.         if (!$this->orderItems->contains($orderItem)) {
  96.             $this->orderItems->add($orderItem);
  97.             $orderItem->setProductPrice($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function removeOrderItem(OrderItem $orderItem): static
  102.     {
  103.         if ($this->orderItems->removeElement($orderItem)) {
  104.             // set the owning side to null (unless already changed)
  105.             if ($orderItem->getProductPrice() === $this) {
  106.                 $orderItem->setProductPrice(null);
  107.             }
  108.         }
  109.         return $this;
  110.     }
  111. }