src/Entity/Product/Product.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Product;
  3. use App\Entity\Components\HardComponent;
  4. use App\Entity\Gallery\Gallery;
  5. use App\Entity\Order\SaleItem;
  6. use App\Repository\Product\ProductRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. #[ORM\Entity(repositoryClassProductRepository::class)]
  12. class Product
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length255)]
  19.     private ?string $name null;
  20.     #[ORM\Column]
  21.     private ?bool $is_activ null;
  22.     #[ORM\Column(typeTypes::TEXT)]
  23.     private ?string $content null;
  24.     #[ORM\Column(length255)]
  25.     private ?string $slug null;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  27.     private ?\DateTimeInterface $created_at null;
  28.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  29.     private ?\DateTimeInterface $updated_at null;
  30.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  31.     private ?\DateTimeInterface $published_at null;
  32.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  33.     private ?string $price null;
  34.     #[ORM\Column(length355nullabletrue)]
  35.     private ?string $preview null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $reference null;
  38.     #[ORM\Column(length255nullabletrue)]
  39.     private ?string $collection null;
  40.     #[ORM\Column(length355nullabletrue)]
  41.     private ?string $metaDescription null;
  42.     #[ORM\Column(length255nullabletrue)]
  43.     private ?string $pdfName null;
  44.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  45.     private ?string $draft null;
  46.     #[ORM\ManyToOne(inversedBy'product')]
  47.     private ?Brand $brand null;
  48.     #[ORM\Column(length30nullabletrue)]
  49.     private ?string $skeleton null;
  50.     #[ORM\ManyToOne]
  51.     private ?HardComponent $hardComponent null;
  52.     #[ORM\OneToMany(mappedBy'product'targetEntityProductVariant::class, cascade: ['persist''remove'])]
  53.     private Collection $productVariants;
  54.     #[ORM\OneToMany(mappedBy'product'targetEntityProductAttributeValue::class)]
  55.     private Collection $productAttributeValues;
  56.     #[ORM\ManyToMany(targetEntityProductCategory::class, inversedBy'products')]
  57.     private Collection $categories;
  58.     #[ORM\OneToMany(mappedBy'product'targetEntityProductImage::class)]
  59.     private Collection $productImages;
  60.     #[ORM\OneToMany(mappedBy'product'targetEntityProductTag::class)]
  61.     private Collection $productTags;
  62.     #[ORM\Column(nullabletrue)]
  63.     private ?int $stock_quantity null;
  64.     #[ORM\Column(typeTypes::DECIMALprecision3scale2nullabletrue)]
  65.     private ?string $globalNote null;
  66.     #[ORM\OneToMany(mappedBy'product'targetEntityCustomerComment::class)]
  67.     private Collection $customerComments;
  68.     #[ORM\OneToMany(mappedBy'product'targetEntityCustomerNoteProduct::class, cascade: ['persist''remove'])]
  69.     private Collection $customerNotes;
  70.     #[ORM\OneToMany(mappedBy'product'targetEntitySimilarProduct::class, cascade: ['persist''remove'])]
  71.     private Collection $similarProducts;
  72.     #[ORM\OneToMany(mappedBy'similar'targetEntitySimilarProduct::class, cascade: ['persist''remove'])]
  73.     private Collection $similarToProducts;
  74.     #[ORM\OneToMany(mappedBy'product'targetEntityProductBoughtTogether::class)]
  75.     private Collection $productBoughtTogethers;
  76.     #[ORM\OneToOne(mappedBy'product'cascade: ['persist''remove'])]
  77.     private ?SaleItem $saleItem null;
  78.     #[ORM\Column(length50nullabletrue)]
  79.     private ?string $promotion null;
  80.     public function __construct()
  81.     {
  82.         $this->productVariants = new ArrayCollection();
  83.         $this->productAttributeValues = new ArrayCollection();
  84.         $this->categories = new ArrayCollection();
  85.         $this->productImages = new ArrayCollection();
  86.         $this->productTags = new ArrayCollection();
  87.         $this->customerComments = new ArrayCollection();
  88.         $this->customerNotes = new ArrayCollection();
  89.         $this->similarProducts = new ArrayCollection();
  90.         $this->similarToProducts = new ArrayCollection();
  91.         $this->productBoughtTogethers = new ArrayCollection();
  92.     }
  93.     public function getId(): ?int
  94.     {
  95.         return $this->id;
  96.     }
  97.     public function getName(): ?string
  98.     {
  99.         return $this->name;
  100.     }
  101.     public function setName(string $name): self
  102.     {
  103.         $this->name $name;
  104.         return $this;
  105.     }
  106.     public function isIsActiv(): ?bool
  107.     {
  108.         return $this->is_activ;
  109.     }
  110.     public function setIsActiv(bool $is_activ): self
  111.     {
  112.         $this->is_activ $is_activ;
  113.         return $this;
  114.     }
  115.     public function getContent(): ?string
  116.     {
  117.         return $this->content;
  118.     }
  119.     public function setContent(string $content): self
  120.     {
  121.         $this->content $content;
  122.         return $this;
  123.     }
  124.     public function getSlug(): ?string
  125.     {
  126.         return $this->slug;
  127.     }
  128.     public function setSlug(string $slug): self
  129.     {
  130.         $this->slug $slug;
  131.         return $this;
  132.     }
  133.     public function getCreatedAt(): ?\DateTimeInterface
  134.     {
  135.         return $this->created_at;
  136.     }
  137.     public function setCreatedAt(?\DateTimeInterface $created_at): self
  138.     {
  139.         $this->created_at $created_at;
  140.         return $this;
  141.     }
  142.     public function getUpdatedAt(): ?\DateTimeInterface
  143.     {
  144.         return $this->updated_at;
  145.     }
  146.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  147.     {
  148.         $this->updated_at $updated_at;
  149.         return $this;
  150.     }
  151.     public function getPublishedAt(): ?\DateTimeInterface
  152.     {
  153.         return $this->published_at;
  154.     }
  155.     public function setPublishedAt(?\DateTimeInterface $published_at): self
  156.     {
  157.         $this->published_at $published_at;
  158.         return $this;
  159.     }
  160.     public function getPrice(): ?string
  161.     {
  162.         return $this->price;
  163.     }
  164.     public function setPrice(string $price): self
  165.     {
  166.         $this->price $price;
  167.         return $this;
  168.     }
  169.     public function getPreview(): ?string
  170.     {
  171.         return $this->preview;
  172.     }
  173.     public function setPreview(?string $preview): self
  174.     {
  175.         $this->preview $preview;
  176.         return $this;
  177.     }
  178.     public function getReference(): ?string
  179.     {
  180.         return $this->reference;
  181.     }
  182.     public function setReference(?string $reference): self
  183.     {
  184.         $this->reference $reference;
  185.         return $this;
  186.     }
  187.     public function getCollection(): ?string
  188.     {
  189.         return $this->collection;
  190.     }
  191.     public function setCollection(?string $collection): self
  192.     {
  193.         $this->collection $collection;
  194.         return $this;
  195.     }
  196.     public function getMetaDescription(): ?string
  197.     {
  198.         return $this->metaDescription;
  199.     }
  200.     public function setMetaDescription(?string $metaDescription): self
  201.     {
  202.         $this->metaDescription $metaDescription;
  203.         return $this;
  204.     }
  205.     public function getPdfName(): ?string
  206.     {
  207.         return $this->pdfName;
  208.     }
  209.     public function setPdfName(?string $pdfName): self
  210.     {
  211.         $this->pdfName $pdfName;
  212.         return $this;
  213.     }
  214.     public function getDraft(): ?string
  215.     {
  216.         return $this->draft;
  217.     }
  218.     public function setDraft(?string $draft): self
  219.     {
  220.         $this->draft $draft;
  221.         return $this;
  222.     }
  223.     public function getBrand(): ?Brand
  224.     {
  225.         return $this->brand;
  226.     }
  227.     public function setBrand(?Brand $brand): self
  228.     {
  229.         $this->brand $brand;
  230.         return $this;
  231.     }
  232.     public function getSkeleton(): ?string
  233.     {
  234.         return $this->skeleton;
  235.     }
  236.     public function setSkeleton(?string $skeleton): static
  237.     {
  238.         $this->skeleton $skeleton;
  239.         return $this;
  240.     }
  241.     public function getHardComponent(): ?HardComponent
  242.     {
  243.         return $this->hardComponent;
  244.     }
  245.     public function setHardComponent(?HardComponent $hardComponent): static
  246.     {
  247.         $this->hardComponent $hardComponent;
  248.         return $this;
  249.     }
  250.     /**
  251.      * @return Collection<int, ProductVariant>
  252.      */
  253.     public function getProductVariants(): Collection
  254.     {
  255.         return $this->productVariants;
  256.     }
  257.     public function addProductVariant(ProductVariant $productVariant): static
  258.     {
  259.         if (!$this->productVariants->contains($productVariant)) {
  260.             $this->productVariants->add($productVariant);
  261.             $productVariant->setProduct($this);
  262.         }
  263.         return $this;
  264.     }
  265.     public function removeProductVariant(ProductVariant $productVariant): static
  266.     {
  267.         if ($this->productVariants->removeElement($productVariant)) {
  268.             // set the owning side to null (unless already changed)
  269.             if ($productVariant->getProduct() === $this) {
  270.                 $productVariant->setProduct(null);
  271.             }
  272.         }
  273.         return $this;
  274.     }
  275.     /**
  276.      * @return Collection<int, ProductAttributeValue>
  277.      */
  278.     public function getProductAttributeValues(): Collection
  279.     {
  280.         return $this->productAttributeValues;
  281.     }
  282.     public function addProductAttributeValue(ProductAttributeValue $productAttributeValue): static
  283.     {
  284.         if (!$this->productAttributeValues->contains($productAttributeValue)) {
  285.             $this->productAttributeValues->add($productAttributeValue);
  286.             $productAttributeValue->setProduct($this);
  287.         }
  288.         return $this;
  289.     }
  290.     public function removeProductAttributeValue(ProductAttributeValue $productAttributeValue): static
  291.     {
  292.         if ($this->productAttributeValues->removeElement($productAttributeValue)) {
  293.             // set the owning side to null (unless already changed)
  294.             if ($productAttributeValue->getProduct() === $this) {
  295.                 $productAttributeValue->setProduct(null);
  296.             }
  297.         }
  298.         return $this;
  299.     }
  300.     /**
  301.      * @return Collection<int, ProductCategory>
  302.      */
  303.     public function getCategories(): Collection
  304.     {
  305.         return $this->categories;
  306.     }
  307.     public function addCategory(ProductCategory $category): static
  308.     {
  309.         if (!$this->categories->contains($category)) {
  310.             $this->categories->add($category);
  311.         }
  312.         return $this;
  313.     }
  314.     public function removeCategory(ProductCategory $category): static
  315.     {
  316.         $this->categories->removeElement($category);
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return Collection<int, ProductImage>
  321.      */
  322.     public function getProductImages(): Collection
  323.     {
  324.         return $this->productImages;
  325.     }
  326.     public function addProductImage(ProductImage $productImage): static
  327.     {
  328.         if (!$this->productImages->contains($productImage)) {
  329.             $this->productImages->add($productImage);
  330.             $productImage->setProduct($this);
  331.         }
  332.         return $this;
  333.     }
  334.     public function removeProductImage(ProductImage $productImage): static
  335.     {
  336.         if ($this->productImages->removeElement($productImage)) {
  337.             // set the owning side to null (unless already changed)
  338.             if ($productImage->getProduct() === $this) {
  339.                 $productImage->setProduct(null);
  340.             }
  341.         }
  342.         return $this;
  343.     }
  344.     /**
  345.      * @return Collection<int, ProductTag>
  346.      */
  347.     public function getProductTags(): Collection
  348.     {
  349.         return $this->productTags;
  350.     }
  351.     public function addProductTag(ProductTag $productTag): static
  352.     {
  353.         if (!$this->productTags->contains($productTag)) {
  354.             $this->productTags->add($productTag);
  355.             $productTag->setProduct($this);
  356.         }
  357.         return $this;
  358.     }
  359.     public function removeProductTag(ProductTag $productTag): static
  360.     {
  361.         if ($this->productTags->removeElement($productTag)) {
  362.             // set the owning side to null (unless already changed)
  363.             if ($productTag->getProduct() === $this) {
  364.                 $productTag->setProduct(null);
  365.             }
  366.         }
  367.         return $this;
  368.     }
  369.     public function getStockQuantity(): ?int
  370.     {
  371.         return $this->stock_quantity;
  372.     }
  373.     public function setStockQuantity(?int $stock_quantity): static
  374.     {
  375.         $this->stock_quantity $stock_quantity;
  376.         return $this;
  377.     }
  378.     public function getGlobalNote(): ?string
  379.     {
  380.         return $this->globalNote;
  381.     }
  382.     public function setGlobalNote(?string $globalNote): static
  383.     {
  384.         $this->globalNote $globalNote;
  385.         return $this;
  386.     }
  387.     /**
  388.      * @return Collection<int, CustomerComment>
  389.      */
  390.     public function getCustomerComments(): Collection
  391.     {
  392.         return $this->customerComments;
  393.     }
  394.     public function addCustomerComment(CustomerComment $customerComment): static
  395.     {
  396.         if (!$this->customerComments->contains($customerComment)) {
  397.             $this->customerComments->add($customerComment);
  398.             $customerComment->setProduct($this);
  399.         }
  400.         return $this;
  401.     }
  402.     public function removeCustomerComment(CustomerComment $customerComment): static
  403.     {
  404.         if ($this->customerComments->removeElement($customerComment)) {
  405.             // set the owning side to null (unless already changed)
  406.             if ($customerComment->getProduct() === $this) {
  407.                 $customerComment->setProduct(null);
  408.             }
  409.         }
  410.         return $this;
  411.     }
  412.     /**
  413.      * @return Collection<int, CustomerNote>
  414.      */
  415.     public function getCustomerNotes(): Collection
  416.     {
  417.         return $this->customerNotes;
  418.     }
  419.     public function addCustomerNote(CustomerNoteProduct $customerNoteProduct): static
  420.     {
  421.         if (!$this->customerNotes->contains($customerNoteProduct)) {
  422.             $this->customerNotes->add($customerNoteProduct);
  423.             $customerNoteProduct->setProduct($this);
  424.         }
  425.         return $this;
  426.     }
  427.     public function removeCustomerNote(CustomerNoteProduct $customerNoteProduct): static
  428.     {
  429.         if ($this->customerNotes->removeElement($customerNoteProduct)) {
  430.             // set the owning side to null (unless already changed)
  431.             if ($customerNoteProduct->getProduct() === $this) {
  432.                 $customerNoteProduct->setProduct(null);
  433.             }
  434.         }
  435.         return $this;
  436.     }
  437.     /**
  438.      * @return Collection<int, SimilarProduct>
  439.      */
  440.     public function getSimilarProducts(): Collection
  441.     {
  442.         return $this->similarProducts;
  443.     }
  444.     public function addSimilarProduct(SimilarProduct $similarProduct): static
  445.     {
  446.         if (!$this->similarProducts->contains($similarProduct)) {
  447.             $this->similarProducts->add($similarProduct);
  448.             $similarProduct->setProduct($this);
  449.         }
  450.         return $this;
  451.     }
  452.     public function removeSimilarProduct(SimilarProduct $similarProduct): static
  453.     {
  454.         if ($this->similarProducts->removeElement($similarProduct)) {
  455.             // set the owning side to null (unless already changed)
  456.             if ($similarProduct->getProduct() === $this) {
  457.                 $similarProduct->setProduct(null);
  458.             }
  459.         }
  460.         return $this;
  461.     }
  462.     /**
  463.      * @return Collection<int, SimilarProduct>
  464.      */
  465.     public function getSimilarToProducts(): Collection
  466.     {
  467.         return $this->similarToProducts;
  468.     }
  469.     public function addSimilarToProduct(SimilarProduct $similarToProduct): static
  470.     {
  471.         if (!$this->similarToProducts->contains($similarToProduct)) {
  472.             $this->similarToProducts->add($similarToProduct);
  473.             $similarToProduct->setSimilar($this);
  474.         }
  475.         return $this;
  476.     }
  477.     /**
  478.      * @return Collection<int, ProductBoughtTogether>
  479.      */
  480.     public function getProductBoughtTogethers(): Collection
  481.     {
  482.         return $this->productBoughtTogethers;
  483.     }
  484.     public function addProductBoughtTogether(ProductBoughtTogether $productBoughtTogether): static
  485.     {
  486.         if (!$this->productBoughtTogethers->contains($productBoughtTogether)) {
  487.             $this->productBoughtTogethers->add($productBoughtTogether);
  488.             $productBoughtTogether->setProduct($this);
  489.         }
  490.         return $this;
  491.     }
  492.     public function removeProductBoughtTogether(ProductBoughtTogether $productBoughtTogether): static
  493.     {
  494.         if ($this->productBoughtTogethers->removeElement($productBoughtTogether)) {
  495.             // set the owning side to null (unless already changed)
  496.             if ($productBoughtTogether->getProduct() === $this) {
  497.                 $productBoughtTogether->setProduct(null);
  498.             }
  499.         }
  500.         return $this;
  501.     }
  502.     public function getSaleItem(): ?SaleItem
  503.     {
  504.         return $this->saleItem;
  505.     }
  506.     public function setSaleItem(?SaleItem $saleItem): static
  507.     {
  508.         // unset the owning side of the relation if necessary
  509.         if ($saleItem === null && $this->saleItem !== null) {
  510.             $this->saleItem->setProduct(null);
  511.         }
  512.         // set the owning side of the relation if necessary
  513.         if ($saleItem !== null && $saleItem->getProduct() !== $this) {
  514.             $saleItem->setProduct($this);
  515.         }
  516.         $this->saleItem $saleItem;
  517.         return $this;
  518.     }
  519.     public function getPromotion(): ?string
  520.     {
  521.         return $this->promotion;
  522.     }
  523.     public function setPromotion(?string $promotion): static
  524.     {
  525.         $this->promotion $promotion;
  526.         return $this;
  527.     }
  528. }