<?php
namespace App\Entity\Product;
use App\Entity\Components\HardComponent;
use App\Entity\Gallery\Gallery;
use App\Entity\Order\SaleItem;
use App\Repository\Product\ProductRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductRepository::class)]
class Product
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column]
private ?bool $is_activ = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $content = null;
#[ORM\Column(length: 255)]
private ?string $slug = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $created_at = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $updated_at = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $published_at = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]
private ?string $price = null;
#[ORM\Column(length: 355, nullable: true)]
private ?string $preview = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $reference = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $collection = null;
#[ORM\Column(length: 355, nullable: true)]
private ?string $metaDescription = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $pdfName = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $draft = null;
#[ORM\ManyToOne(inversedBy: 'product')]
private ?Brand $brand = null;
#[ORM\Column(length: 30, nullable: true)]
private ?string $skeleton = null;
#[ORM\ManyToOne]
private ?HardComponent $hardComponent = null;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductVariant::class, cascade: ['persist', 'remove'])]
private Collection $productVariants;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductAttributeValue::class)]
private Collection $productAttributeValues;
#[ORM\ManyToMany(targetEntity: ProductCategory::class, inversedBy: 'products')]
private Collection $categories;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductImage::class)]
private Collection $productImages;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductTag::class)]
private Collection $productTags;
#[ORM\Column(nullable: true)]
private ?int $stock_quantity = null;
#[ORM\Column(type: Types::DECIMAL, precision: 3, scale: 2, nullable: true)]
private ?string $globalNote = null;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: CustomerComment::class)]
private Collection $customerComments;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: CustomerNoteProduct::class, cascade: ['persist', 'remove'])]
private Collection $customerNotes;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: SimilarProduct::class, cascade: ['persist', 'remove'])]
private Collection $similarProducts;
#[ORM\OneToMany(mappedBy: 'similar', targetEntity: SimilarProduct::class, cascade: ['persist', 'remove'])]
private Collection $similarToProducts;
#[ORM\OneToMany(mappedBy: 'product', targetEntity: ProductBoughtTogether::class)]
private Collection $productBoughtTogethers;
#[ORM\OneToOne(mappedBy: 'product', cascade: ['persist', 'remove'])]
private ?SaleItem $saleItem = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $promotion = null;
public function __construct()
{
$this->productVariants = new ArrayCollection();
$this->productAttributeValues = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->productImages = new ArrayCollection();
$this->productTags = new ArrayCollection();
$this->customerComments = new ArrayCollection();
$this->customerNotes = new ArrayCollection();
$this->similarProducts = new ArrayCollection();
$this->similarToProducts = new ArrayCollection();
$this->productBoughtTogethers = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function isIsActiv(): ?bool
{
return $this->is_activ;
}
public function setIsActiv(bool $is_activ): self
{
$this->is_activ = $is_activ;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->published_at;
}
public function setPublishedAt(?\DateTimeInterface $published_at): self
{
$this->published_at = $published_at;
return $this;
}
public function getPrice(): ?string
{
return $this->price;
}
public function setPrice(string $price): self
{
$this->price = $price;
return $this;
}
public function getPreview(): ?string
{
return $this->preview;
}
public function setPreview(?string $preview): self
{
$this->preview = $preview;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(?string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getCollection(): ?string
{
return $this->collection;
}
public function setCollection(?string $collection): self
{
$this->collection = $collection;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getPdfName(): ?string
{
return $this->pdfName;
}
public function setPdfName(?string $pdfName): self
{
$this->pdfName = $pdfName;
return $this;
}
public function getDraft(): ?string
{
return $this->draft;
}
public function setDraft(?string $draft): self
{
$this->draft = $draft;
return $this;
}
public function getBrand(): ?Brand
{
return $this->brand;
}
public function setBrand(?Brand $brand): self
{
$this->brand = $brand;
return $this;
}
public function getSkeleton(): ?string
{
return $this->skeleton;
}
public function setSkeleton(?string $skeleton): static
{
$this->skeleton = $skeleton;
return $this;
}
public function getHardComponent(): ?HardComponent
{
return $this->hardComponent;
}
public function setHardComponent(?HardComponent $hardComponent): static
{
$this->hardComponent = $hardComponent;
return $this;
}
/**
* @return Collection<int, ProductVariant>
*/
public function getProductVariants(): Collection
{
return $this->productVariants;
}
public function addProductVariant(ProductVariant $productVariant): static
{
if (!$this->productVariants->contains($productVariant)) {
$this->productVariants->add($productVariant);
$productVariant->setProduct($this);
}
return $this;
}
public function removeProductVariant(ProductVariant $productVariant): static
{
if ($this->productVariants->removeElement($productVariant)) {
// set the owning side to null (unless already changed)
if ($productVariant->getProduct() === $this) {
$productVariant->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductAttributeValue>
*/
public function getProductAttributeValues(): Collection
{
return $this->productAttributeValues;
}
public function addProductAttributeValue(ProductAttributeValue $productAttributeValue): static
{
if (!$this->productAttributeValues->contains($productAttributeValue)) {
$this->productAttributeValues->add($productAttributeValue);
$productAttributeValue->setProduct($this);
}
return $this;
}
public function removeProductAttributeValue(ProductAttributeValue $productAttributeValue): static
{
if ($this->productAttributeValues->removeElement($productAttributeValue)) {
// set the owning side to null (unless already changed)
if ($productAttributeValue->getProduct() === $this) {
$productAttributeValue->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductCategory>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(ProductCategory $category): static
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
}
return $this;
}
public function removeCategory(ProductCategory $category): static
{
$this->categories->removeElement($category);
return $this;
}
/**
* @return Collection<int, ProductImage>
*/
public function getProductImages(): Collection
{
return $this->productImages;
}
public function addProductImage(ProductImage $productImage): static
{
if (!$this->productImages->contains($productImage)) {
$this->productImages->add($productImage);
$productImage->setProduct($this);
}
return $this;
}
public function removeProductImage(ProductImage $productImage): static
{
if ($this->productImages->removeElement($productImage)) {
// set the owning side to null (unless already changed)
if ($productImage->getProduct() === $this) {
$productImage->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, ProductTag>
*/
public function getProductTags(): Collection
{
return $this->productTags;
}
public function addProductTag(ProductTag $productTag): static
{
if (!$this->productTags->contains($productTag)) {
$this->productTags->add($productTag);
$productTag->setProduct($this);
}
return $this;
}
public function removeProductTag(ProductTag $productTag): static
{
if ($this->productTags->removeElement($productTag)) {
// set the owning side to null (unless already changed)
if ($productTag->getProduct() === $this) {
$productTag->setProduct(null);
}
}
return $this;
}
public function getStockQuantity(): ?int
{
return $this->stock_quantity;
}
public function setStockQuantity(?int $stock_quantity): static
{
$this->stock_quantity = $stock_quantity;
return $this;
}
public function getGlobalNote(): ?string
{
return $this->globalNote;
}
public function setGlobalNote(?string $globalNote): static
{
$this->globalNote = $globalNote;
return $this;
}
/**
* @return Collection<int, CustomerComment>
*/
public function getCustomerComments(): Collection
{
return $this->customerComments;
}
public function addCustomerComment(CustomerComment $customerComment): static
{
if (!$this->customerComments->contains($customerComment)) {
$this->customerComments->add($customerComment);
$customerComment->setProduct($this);
}
return $this;
}
public function removeCustomerComment(CustomerComment $customerComment): static
{
if ($this->customerComments->removeElement($customerComment)) {
// set the owning side to null (unless already changed)
if ($customerComment->getProduct() === $this) {
$customerComment->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, CustomerNote>
*/
public function getCustomerNotes(): Collection
{
return $this->customerNotes;
}
public function addCustomerNote(CustomerNoteProduct $customerNoteProduct): static
{
if (!$this->customerNotes->contains($customerNoteProduct)) {
$this->customerNotes->add($customerNoteProduct);
$customerNoteProduct->setProduct($this);
}
return $this;
}
public function removeCustomerNote(CustomerNoteProduct $customerNoteProduct): static
{
if ($this->customerNotes->removeElement($customerNoteProduct)) {
// set the owning side to null (unless already changed)
if ($customerNoteProduct->getProduct() === $this) {
$customerNoteProduct->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, SimilarProduct>
*/
public function getSimilarProducts(): Collection
{
return $this->similarProducts;
}
public function addSimilarProduct(SimilarProduct $similarProduct): static
{
if (!$this->similarProducts->contains($similarProduct)) {
$this->similarProducts->add($similarProduct);
$similarProduct->setProduct($this);
}
return $this;
}
public function removeSimilarProduct(SimilarProduct $similarProduct): static
{
if ($this->similarProducts->removeElement($similarProduct)) {
// set the owning side to null (unless already changed)
if ($similarProduct->getProduct() === $this) {
$similarProduct->setProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, SimilarProduct>
*/
public function getSimilarToProducts(): Collection
{
return $this->similarToProducts;
}
public function addSimilarToProduct(SimilarProduct $similarToProduct): static
{
if (!$this->similarToProducts->contains($similarToProduct)) {
$this->similarToProducts->add($similarToProduct);
$similarToProduct->setSimilar($this);
}
return $this;
}
/**
* @return Collection<int, ProductBoughtTogether>
*/
public function getProductBoughtTogethers(): Collection
{
return $this->productBoughtTogethers;
}
public function addProductBoughtTogether(ProductBoughtTogether $productBoughtTogether): static
{
if (!$this->productBoughtTogethers->contains($productBoughtTogether)) {
$this->productBoughtTogethers->add($productBoughtTogether);
$productBoughtTogether->setProduct($this);
}
return $this;
}
public function removeProductBoughtTogether(ProductBoughtTogether $productBoughtTogether): static
{
if ($this->productBoughtTogethers->removeElement($productBoughtTogether)) {
// set the owning side to null (unless already changed)
if ($productBoughtTogether->getProduct() === $this) {
$productBoughtTogether->setProduct(null);
}
}
return $this;
}
public function getSaleItem(): ?SaleItem
{
return $this->saleItem;
}
public function setSaleItem(?SaleItem $saleItem): static
{
// unset the owning side of the relation if necessary
if ($saleItem === null && $this->saleItem !== null) {
$this->saleItem->setProduct(null);
}
// set the owning side of the relation if necessary
if ($saleItem !== null && $saleItem->getProduct() !== $this) {
$saleItem->setProduct($this);
}
$this->saleItem = $saleItem;
return $this;
}
public function getPromotion(): ?string
{
return $this->promotion;
}
public function setPromotion(?string $promotion): static
{
$this->promotion = $promotion;
return $this;
}
}