src/Entity/Product/ProductVariant.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Product;
  3. use App\Entity\Order\SaleItem;
  4. use App\Repository\Product\ProductVariantRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassProductVariantRepository::class)]
  10. class ProductVariant
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length150)]
  17.     private ?string $name null;
  18.     #[ORM\ManyToOne(inversedBy'productVariants'cascade: ['persist'])]
  19.     private ?Product $product null;
  20.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  21.     private ?string $price null;
  22.     #[ORM\Column(nullabletrue)]
  23.     private ?int $stock_quantity null;
  24.     #[ORM\Column(length50nullabletrue)]
  25.     private ?string $reference null;
  26.     #[ORM\Column(length60nullabletrue)]
  27.     private ?string $slug null;
  28.     #[ORM\OneToMany(mappedBy'productVariant'targetEntityProductAttributeValue::class, cascade: ['persist''remove'])]
  29.     private Collection $productAttributesValues;
  30.     #[ORM\OneToMany(mappedBy'productVariant'targetEntityProductImage::class)]
  31.     private Collection $productImages;
  32.     #[ORM\OneToOne(mappedBy'productVariant'cascade: ['persist''remove'])]
  33.     private ?SaleItem $saleItem null;
  34.     #[ORM\Column(length50nullabletrue)]
  35.     private ?string $promotion null;
  36.     public function __construct()
  37.     {
  38.         $this->productAttributesValues = new ArrayCollection();
  39.         $this->productImages = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getName(): ?string
  46.     {
  47.         return $this->name;
  48.     }
  49.     public function setName(?string $name): static
  50.     {
  51.         $this->name $name;
  52.         return $this;
  53.     }
  54.     public function getProduct(): ?Product
  55.     {
  56.         return $this->product;
  57.     }
  58.     public function setProduct(?Product $product): static
  59.     {
  60.         $this->product $product;
  61.         return $this;
  62.     }
  63.     public function getPrice(): ?string
  64.     {
  65.         return $this->price;
  66.     }
  67.     public function setPrice(?string $price): static
  68.     {
  69.         $this->price $price;
  70.         return $this;
  71.     }
  72.     public function getStockQuantity(): ?int
  73.     {
  74.         return $this->stock_quantity;
  75.     }
  76.     public function setStockQuantity(?int $stock_quantity): static
  77.     {
  78.         $this->stock_quantity $stock_quantity;
  79.         return $this;
  80.     }
  81.     public function getReference(): ?string
  82.     {
  83.         return $this->reference;
  84.     }
  85.     public function setReference(?string $reference): static
  86.     {
  87.         $this->reference $reference;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection<int, ProductAttributeValue>
  92.      */
  93.     public function getProductAttributesValues(): Collection
  94.     {
  95.         return $this->productAttributesValues;
  96.     }
  97.     public function addProductAttributesValue(ProductAttributeValue $productAttributesValue): static
  98.     {
  99.         if (!$this->productAttributesValues->contains($productAttributesValue)) {
  100.             $this->productAttributesValues->add($productAttributesValue);
  101.             $productAttributesValue->setProductVariant($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeProductAttributesValue(ProductAttributeValue $productAttributesValue): static
  106.     {
  107.         if ($this->productAttributesValues->removeElement($productAttributesValue)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($productAttributesValue->getProductVariant() === $this) {
  110.                 $productAttributesValue->setProductVariant(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection<int, ProductImage>
  117.      */
  118.     public function getProductImages(): Collection
  119.     {
  120.         return $this->productImages;
  121.     }
  122.     public function addProductImage(ProductImage $productImage): static
  123.     {
  124.         if (!$this->productImages->contains($productImage)) {
  125.             $this->productImages->add($productImage);
  126.             $productImage->setProductVariant($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeProductImage(ProductImage $productImage): static
  131.     {
  132.         if ($this->productImages->removeElement($productImage)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($productImage->getProductVariant() === $this) {
  135.                 $productImage->setProductVariant(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140.     public function getSlug(): ?string
  141.     {
  142.         return $this->slug;
  143.     }
  144.     public function setSlug(?string $slug): static
  145.     {
  146.         $this->slug $slug;
  147.         return $this;
  148.     }
  149.     public function getSaleItem(): ?SaleItem
  150.     {
  151.         return $this->saleItem;
  152.     }
  153.     public function setSaleItem(?SaleItem $saleItem): static
  154.     {
  155.         // unset the owning side of the relation if necessary
  156.         if ($saleItem === null && $this->saleItem !== null) {
  157.             $this->saleItem->setProductVariant(null);
  158.         }
  159.         // set the owning side of the relation if necessary
  160.         if ($saleItem !== null && $saleItem->getProductVariant() !== $this) {
  161.             $saleItem->setProductVariant($this);
  162.         }
  163.         $this->saleItem $saleItem;
  164.         return $this;
  165.     }
  166.     public function getPromotion(): ?string
  167.     {
  168.         return $this->promotion;
  169.     }
  170.     public function setPromotion(?string $promotion): static
  171.     {
  172.         $this->promotion $promotion;
  173.         return $this;
  174.     }
  175. }