<?php
namespace App\Entity;
use App\Repository\ProductsSizesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProductsSizesRepository::class)]
class ProductsSizes
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'productsSizes')]
#[ORM\JoinColumn(nullable: false)]
private ?Product $product = null;
#[ORM\ManyToOne(inversedBy: 'productsSizes')]
#[ORM\JoinColumn(nullable: false)]
private ?Sizes $size = null;
#[ORM\Column]
private ?int $count = null;
#[ORM\OneToMany(mappedBy: 'size', targetEntity: ShopCart::class)]
private Collection $shopCartItem;
#[ORM\OneToMany(mappedBy: 'productsSizes', targetEntity: OrderProductsSizes::class, orphanRemoval: true)]
private Collection $orderProductsSizes;
public function __construct()
{
$this->shopCartItem = new ArrayCollection();
$this->orderProductsSizes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): self
{
$this->product = $product;
return $this;
}
public function getSize(): ?Sizes
{
return $this->size;
}
public function setSize(?Sizes $size): self
{
$this->size = $size;
return $this;
}
public function getCount(): ?int
{
return $this->count;
}
public function setCount(int $count): self
{
$this->count = $count;
return $this;
}
/**
* @return Collection<int, ShopCart>
*/
public function getShopCartItem(): Collection
{
return $this->shopCartItem;
}
/**
* @param ShopCart $shopCartItem
* @return $this
*/
public function addShopCartItem(ShopCart $shopCartItem): self
{
if (!$this->shopCartItem->contains($shopCartItem)) {
$this->shopCartItem->add($shopCartItem);
$shopCartItem->setSize($this);
}
return $this;
}
/**
* @param ShopCart $shopCartItem
* @return $this
*/
public function removeShopCartItem(ShopCart $shopCartItem): self
{
if ($this->shopCartItem->removeElement($shopCartItem)) {
// set the owning side to null (unless already changed)
if ($shopCartItem->getSize() === $this) {
$shopCartItem->setSize(null);
}
}
return $this;
}
/**
* @return Collection<int, OrderProductsSizes>
*/
public function getOrderProductsSizes(): Collection
{
return $this->orderProductsSizes;
}
/**
* @param OrderProductsSizes $orderProductsSize
* @return $this
*/
public function addOrderProductsSize(OrderProductsSizes $orderProductsSize): static
{
if (!$this->orderProductsSizes->contains($orderProductsSize)) {
$this->orderProductsSizes->add($orderProductsSize);
$orderProductsSize->setProductsSizes($this);
}
return $this;
}
/**
* @param OrderProductsSizes $orderProductsSize
* @return $this
*/
public function removeOrderProductsSize(OrderProductsSizes $orderProductsSize): static
{
if ($this->orderProductsSizes->removeElement($orderProductsSize)) {
// set the owning side to null (unless already changed)
if ($orderProductsSize->getProductsSizes() === $this) {
$orderProductsSize->setProductsSizes(null);
}
}
return $this;
}
}