src/Entity/Order/SaleItem.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Order;
  3. use App\Entity\Product\Product;
  4. use App\Entity\Product\ProductVariant;
  5. use App\Entity\User\Wish;
  6. use App\Repository\Order\SaleItemRepository;
  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(repositoryClassSaleItemRepository::class)]
  12. class SaleItem
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column]
  19.     private ?int $reference_id null;
  20.     #[ORM\Column(length50)]
  21.     private ?string $type null;
  22.     #[ORM\Column(length255)]
  23.     private ?string $title null;
  24.     #[ORM\Column(length20)]
  25.     private string $stockStatus 'in_stock'// in_stock, out_of_stock, preorder
  26.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  27.     private ?string $description null;
  28.     #[ORM\Column(length255nullabletrue)]
  29.     private ?string $sku null;
  30.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  31.     private ?string $stock '0';
  32.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  33.     private ?string $price_ht '0';
  34.     #[ORM\Column(typeTypes::DECIMALprecision10scale2)]
  35.     private ?string $price_ttc '0';
  36.     #[ORM\Column(typeTypes::DECIMALprecision5scale2)]
  37.     private ?string $tax_rate '20';
  38.     #[ORM\Column(length10)]
  39.     private ?string $currency 'EUR';
  40.     #[ORM\Column(typeTypes::DECIMALprecision10scale2nullabletrue)]
  41.     private ?string $discount_amount null;
  42.     #[ORM\Column(typeTypes::DECIMALprecision5scale2nullabletrue)]
  43.     private ?string $discount_percent null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?bool $is_active true;
  46.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  47.     private ?\DateTimeInterface $created_at null;
  48.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  49.     private ?\DateTimeInterface $updated_at null;
  50.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  51.     private ?\DateTimeInterface $discountbegin_at null;
  52.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  53.     private ?\DateTimeInterface $discountend_at null;
  54.     #[ORM\OneToOne(inversedBy'saleItem'cascade: ['persist''remove'])]
  55.     private ?Product $product null;
  56.     #[ORM\OneToOne(inversedBy'saleItem'cascade: ['persist''remove'])]
  57.     private ?ProductVariant $productVariant null;
  58.     #[ORM\OneToMany(mappedBy'saleItem'targetEntityCartItem::class)]
  59.     private Collection $cartItems;
  60.     #[ORM\OneToMany(mappedBy'saleItem'targetEntityOrderItem::class)]
  61.     private Collection $orderItems;
  62.     #[ORM\OneToMany(mappedBy'saleItem'targetEntityWish::class)]
  63.     private Collection $wishes;
  64.     public function __construct()
  65.     {
  66.         $this->cartItems = new ArrayCollection();
  67.         $this->orderItems = new ArrayCollection();
  68.         $this->wishes = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getReferenceId(): ?int
  75.     {
  76.         return $this->reference_id;
  77.     }
  78.     public function setReferenceId(int $reference_id): static
  79.     {
  80.         $this->reference_id $reference_id;
  81.         return $this;
  82.     }
  83.     public function getType(): ?string
  84.     {
  85.         return $this->type;
  86.     }
  87.     public function setType(string $type): static
  88.     {
  89.         $this->type $type;
  90.         return $this;
  91.     }
  92.     public function getTitle(): ?string
  93.     {
  94.         return $this->title;
  95.     }
  96.     public function setTitle(string $title): static
  97.     {
  98.         $this->title $title;
  99.         return $this;
  100.     }
  101.     public function getStockStatus(): ?string
  102.     {
  103.         return $this->stockStatus;
  104.     }
  105.     public function setStockStatus(string $stockStatus): static
  106.     {
  107.         $this->stockStatus $stockStatus;
  108.         return $this;
  109.     }
  110.     public function getDescription(): ?string
  111.     {
  112.         return $this->description;
  113.     }
  114.     public function setDescription(?string $description): static
  115.     {
  116.         $this->description $description;
  117.         return $this;
  118.     }
  119.     public function getSku(): ?string
  120.     {
  121.         return $this->sku;
  122.     }
  123.     public function setSku(?string $sku): static
  124.     {
  125.         $this->sku $sku;
  126.         return $this;
  127.     }
  128.     public function getStock(): ?int
  129.     {
  130.         return $this->stock;
  131.     }
  132.     public function setStock(?int $stock): static
  133.     {
  134.         $this->stock $stock;
  135.         return $this;
  136.     }
  137.     public function getPriceHt(): ?string
  138.     {
  139.         return $this->price_ht;
  140.     }
  141.     public function setPriceHt(string $price_ht): static
  142.     {
  143.         $this->price_ht $price_ht;
  144.         return $this;
  145.     }
  146.     public function getPriceTtc(): ?string
  147.     {
  148.         return $this->price_ttc;
  149.     }
  150.     public function setPriceTtc(string $price_ttc): static
  151.     {
  152.         $this->price_ttc $price_ttc;
  153.         return $this;
  154.     }
  155.     public function getTaxRate(): ?string
  156.     {
  157.         return $this->tax_rate;
  158.     }
  159.     public function setTaxRate(string $tax_rate): static
  160.     {
  161.         $this->tax_rate $tax_rate;
  162.         return $this;
  163.     }
  164.     public function getCurrency(): ?string
  165.     {
  166.         return $this->currency;
  167.     }
  168.     public function setCurrency(string $currency): static
  169.     {
  170.         $this->currency $currency;
  171.         return $this;
  172.     }
  173.     public function getDiscountAmount(): ?string
  174.     {
  175.         return $this->discount_amount;
  176.     }
  177.     public function setDiscountAmount(?string $discount_amount): static
  178.     {
  179.         $this->discount_amount $discount_amount;
  180.         return $this;
  181.     }
  182.     public function getDiscountPercent(): ?string
  183.     {
  184.         return $this->discount_percent;
  185.     }
  186.     public function setDiscountPercent(string $discount_percent): static
  187.     {
  188.         $this->discount_percent $discount_percent;
  189.         return $this;
  190.     }
  191.     public function isIsActive(): ?bool
  192.     {
  193.         return $this->is_active;
  194.     }
  195.     public function setIsActive(?bool $is_active): static
  196.     {
  197.         $this->is_active $is_active;
  198.         return $this;
  199.     }
  200.     public function getCreatedAt(): ?\DateTimeInterface
  201.     {
  202.         return $this->created_at;
  203.     }
  204.     public function setCreatedAt(\DateTimeInterface $created_at): static
  205.     {
  206.         $this->created_at $created_at;
  207.         return $this;
  208.     }
  209.     public function getUpdatedAt(): ?\DateTimeInterface
  210.     {
  211.         return $this->updated_at;
  212.     }
  213.     public function setUpdatedAt(\DateTimeInterface $updated_at): static
  214.     {
  215.         $this->updated_at $updated_at;
  216.         return $this;
  217.     }
  218.     public function getDiscountbeginAt(): ?\DateTimeInterface
  219.     {
  220.         return $this->discountbegin_at;
  221.     }
  222.     public function setDiscountbeginAt(?\DateTimeInterface $discountbegin_at): static
  223.     {
  224.         $this->discountbegin_at $discountbegin_at;
  225.         return $this;
  226.     }
  227.     public function getDiscountendAt(): ?\DateTimeInterface
  228.     {
  229.         return $this->discountend_at;
  230.     }
  231.     public function setDiscountendAt(?\DateTimeInterface $discountend_at): static
  232.     {
  233.         $this->discountend_at $discountend_at;
  234.         return $this;
  235.     }
  236.     public function getProduct(): ?Product
  237.     {
  238.         return $this->product;
  239.     }
  240.     public function setProduct(?Product $product): static
  241.     {
  242.         $this->product $product;
  243.         return $this;
  244.     }
  245.     public function getProductVariant(): ?ProductVariant
  246.     {
  247.         return $this->productVariant;
  248.     }
  249.     public function setProductVariant(?ProductVariant $productVariant): static
  250.     {
  251.         $this->productVariant $productVariant;
  252.         return $this;
  253.     }
  254.     /**
  255.      * @return Collection<int, CartItem>
  256.      */
  257.     public function getCartItems(): Collection
  258.     {
  259.         return $this->cartItems;
  260.     }
  261.     public function addCartItem(CartItem $cartItem): static
  262.     {
  263.         if (!$this->cartItems->contains($cartItem)) {
  264.             $this->cartItems->add($cartItem);
  265.             $cartItem->setSaleItem($this);
  266.         }
  267.         return $this;
  268.     }
  269.     public function removeCartItem(CartItem $cartItem): static
  270.     {
  271.         if ($this->cartItems->removeElement($cartItem)) {
  272.             // set the owning side to null (unless already changed)
  273.             if ($cartItem->getSaleItem() === $this) {
  274.                 $cartItem->setSaleItem(null);
  275.             }
  276.         }
  277.         return $this;
  278.     }
  279.     /**
  280.      * @return Collection<int, OrderItem>
  281.      */
  282.     public function getOrderItems(): Collection
  283.     {
  284.         return $this->orderItems;
  285.     }
  286.     public function addOrderItem(OrderItem $orderItem): static
  287.     {
  288.         if (!$this->orderItems->contains($orderItem)) {
  289.             $this->orderItems->add($orderItem);
  290.             $orderItem->setSaleItem($this);
  291.         }
  292.         return $this;
  293.     }
  294.     public function removeOrderItem(OrderItem $orderItem): static
  295.     {
  296.         if ($this->orderItems->removeElement($orderItem)) {
  297.             // set the owning side to null (unless already changed)
  298.             if ($orderItem->getSaleItem() === $this) {
  299.                 $orderItem->setSaleItem(null);
  300.             }
  301.         }
  302.         return $this;
  303.     }
  304.     /**
  305.      * @return Collection<int, Wish>
  306.      */
  307.     public function getWishes(): Collection
  308.     {
  309.         return $this->wishes;
  310.     }
  311.     public function addWish(Wish $wish): static
  312.     {
  313.         if (!$this->wishes->contains($wish)) {
  314.             $this->wishes->add($wish);
  315.             $wish->setSaleItem($this);
  316.         }
  317.         return $this;
  318.     }
  319.     public function removeWish(Wish $wish): static
  320.     {
  321.         if ($this->wishes->removeElement($wish)) {
  322.             // set the owning side to null (unless already changed)
  323.             if ($wish->getSaleItem() === $this) {
  324.                 $wish->setSaleItem(null);
  325.             }
  326.         }
  327.         return $this;
  328.     }
  329. }