<?php
namespace App\Entity;
use App\Repository\CartRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CartRepository::class)
*/
class Cart
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="datetime")
*/
private $Date;
/**
* @ORM\ManyToOne(targetEntity=Order::class, inversedBy="carts")
*/
private $order;
/**
* @ORM\ManyToOne(targetEntity=Stock::class, inversedBy="carts")
*/
private $stock;
/**
* @ORM\Column(type="integer")
*/
private $qty;
/**
* @ORM\Column(type="integer")
*/
private $price;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $sku;
/**
* @ORM\OneToMany(targetEntity=Imei::class, mappedBy="cart")
*/
private $imei;
/**
* @ORM\ManyToMany(targetEntity=Option::class, mappedBy="cart", cascade={"persist"})
*/
private $options;
/**
* @ORM\ManyToMany(targetEntity=Attribute::class, mappedBy="cart", cascade={"persist"})
*/
private $attributes;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $optionPrice;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $attributePrice;
/**
* @ORM\OneToMany(targetEntity=Sav::class, mappedBy="cart")
*/
private $savs;
public function __construct()
{
$this->imei = new ArrayCollection();
$this->options = new ArrayCollection();
$this->attributes = new ArrayCollection();
$this->savs = new ArrayCollection();
}
public function __toString() {
return (string)$this->getId();
}
public function getId(): ?int
{
return $this->id;
}
public function getDate(): ?\DateTimeInterface
{
return $this->Date;
}
public function setDate(\DateTimeInterface $Date): self
{
$this->Date = $Date;
return $this;
}
public function getOrder(): ?Order
{
return $this->order;
}
public function setOrder(?Order $order): self
{
$this->order = $order;
return $this;
}
public function getStock(): ?Stock
{
return $this->stock;
}
public function setStock(?Stock $stock): self
{
$this->stock = $stock;
return $this;
}
public function getQty(): ?int
{
return $this->qty;
}
public function setQty(int $qty): self
{
$this->qty = $qty;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(int $price): self
{
$this->price = $price;
return $this;
}
public function getSku(): ?string
{
return $this->sku;
}
public function setSku(?string $sku): self
{
$this->sku = $sku;
return $this;
}
/**
* @return Collection<int, Imei>
*/
public function getImei(): Collection
{
return $this->imei;
}
public function addImei(Imei $imei): self
{
if (!$this->imei->contains($imei)) {
$this->imei[] = $imei;
$imei->setCart($this);
}
return $this;
}
public function removeImei(Imei $imei): self
{
if ($this->imei->removeElement($imei)) {
// set the owning side to null (unless already changed)
if ($imei->getCart() === $this) {
$imei->setCart(null);
}
}
return $this;
}
/**
* @return Collection<int, Option>
*/
public function getOptions(): Collection
{
return $this->options;
}
public function addOption(Option $option): static
{
if (!$this->options->contains($option)) {
$this->options->add($option);
$option->addCart($this);
}
return $this;
}
public function removeOption(Option $option): static
{
if ($this->options->removeElement($option)) {
$option->removeCart($this);
}
return $this;
}
public function getOptionPrice(): ?int
{
return $this->optionPrice;
}
public function setOptionPrice(int $optionPrice): static
{
$this->optionPrice = $optionPrice;
return $this;
}
/**
* @return Collection<int, Attribute>
*/
public function getAttributes(): Collection
{
return $this->attributes;
}
public function addAttribute(Attribute $attribute): static
{
if (!$this->attributes->contains($attribute)) {
$this->attributes->add($attribute);
$attribute->addCart($this);
}
return $this;
}
public function removeAttribute(Attribute $attribute): static
{
if ($this->attributes->removeElement($attribute)) {
$attribute->removeCart($this);
}
return $this;
}
public function getAttributePrice(): ?int
{
return $this->attributePrice;
}
public function setAttributePrice(int $attributePrice): static
{
$this->attributePrice = $attributePrice;
return $this;
}
/**
* @return Collection<int, Sav>
*/
public function getSavs(): Collection
{
return $this->savs;
}
public function addSav(Sav $sav): static
{
if (!$this->savs->contains($sav)) {
$this->savs->add($sav);
$sav->setCart($this);
}
return $this;
}
public function removeSav(Sav $sav): static
{
if ($this->savs->removeElement($sav)) {
// set the owning side to null (unless already changed)
if ($sav->getCart() === $this) {
$sav->setCart(null);
}
}
return $this;
}
}