src/Entity/Cart.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CartRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CartRepository::class)
  10.  */
  11. class Cart
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="datetime")
  21.      */
  22.     private $Date;
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity=Order::class, inversedBy="carts")
  25.      */
  26.     private $order;
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=Stock::class, inversedBy="carts")
  29.      */
  30.     private $stock;
  31.     /**
  32.      * @ORM\Column(type="integer")
  33.      */
  34.     private $qty;
  35.     /**
  36.      * @ORM\Column(type="integer")
  37.      */
  38.     private $price;
  39.     /**
  40.      * @ORM\Column(type="string", length=64, nullable=true)
  41.      */
  42.     private $sku;
  43.     /**
  44.      * @ORM\OneToMany(targetEntity=Imei::class, mappedBy="cart")
  45.      */
  46.     private $imei;
  47.     /**
  48.      * @ORM\ManyToMany(targetEntity=Option::class, mappedBy="cart", cascade={"persist"})
  49.      */
  50.     private $options;
  51.     /**
  52.      * @ORM\ManyToMany(targetEntity=Attribute::class, mappedBy="cart", cascade={"persist"})
  53.      */
  54.     private $attributes;
  55.     /**
  56.      * @ORM\Column(type="integer", nullable=true)
  57.      */
  58.     private $optionPrice;
  59.     /**
  60.      * @ORM\Column(type="integer", nullable=true)
  61.      */
  62.     private $attributePrice;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity=Sav::class, mappedBy="cart")
  65.      */
  66.     private $savs;
  67.     public function __construct()
  68.     {
  69.         $this->imei = new ArrayCollection();
  70.         $this->options = new ArrayCollection();
  71.         $this->attributes = new ArrayCollection();
  72.         $this->savs = new ArrayCollection();
  73.     }
  74.     public function __toString() {
  75.         return (string)$this->getId();
  76.     }
  77.     public function getId(): ?int
  78.     {
  79.         return $this->id;
  80.     }
  81.     public function getDate(): ?\DateTimeInterface
  82.     {
  83.         return $this->Date;
  84.     }
  85.     public function setDate(\DateTimeInterface $Date): self
  86.     {
  87.         $this->Date $Date;
  88.         return $this;
  89.     }
  90.     public function getOrder(): ?Order
  91.     {
  92.         return $this->order;
  93.     }
  94.     public function setOrder(?Order $order): self
  95.     {
  96.         $this->order $order;
  97.         return $this;
  98.     }
  99.     public function getStock(): ?Stock
  100.     {
  101.         return $this->stock;
  102.     }
  103.     public function setStock(?Stock $stock): self
  104.     {
  105.         $this->stock $stock;
  106.         return $this;
  107.     }
  108.     public function getQty(): ?int
  109.     {
  110.         return $this->qty;
  111.     }
  112.     public function setQty(int $qty): self
  113.     {
  114.         $this->qty $qty;
  115.         return $this;
  116.     }
  117.     public function getPrice(): ?int
  118.     {
  119.         return $this->price;
  120.     }
  121.     public function setPrice(int $price): self
  122.     {
  123.         $this->price $price;
  124.         return $this;
  125.     }
  126.     public function getSku(): ?string
  127.     {
  128.         return $this->sku;
  129.     }
  130.     public function setSku(?string $sku): self
  131.     {
  132.         $this->sku $sku;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @return Collection<int, Imei>
  137.      */
  138.     public function getImei(): Collection
  139.     {
  140.         return $this->imei;
  141.     }
  142.     public function addImei(Imei $imei): self
  143.     {
  144.         if (!$this->imei->contains($imei)) {
  145.             $this->imei[] = $imei;
  146.             $imei->setCart($this);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeImei(Imei $imei): self
  151.     {
  152.         if ($this->imei->removeElement($imei)) {
  153.             // set the owning side to null (unless already changed)
  154.             if ($imei->getCart() === $this) {
  155.                 $imei->setCart(null);
  156.             }
  157.         }
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, Option>
  162.      */
  163.     public function getOptions(): Collection
  164.     {
  165.         return $this->options;
  166.     }
  167.     public function addOption(Option $option): static
  168.     {
  169.         if (!$this->options->contains($option)) {
  170.             $this->options->add($option);
  171.             $option->addCart($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeOption(Option $option): static
  176.     {
  177.         if ($this->options->removeElement($option)) {
  178.             $option->removeCart($this);
  179.         }
  180.         return $this;
  181.     }
  182.     public function getOptionPrice(): ?int
  183.     {
  184.         return $this->optionPrice;
  185.     }
  186.     public function setOptionPrice(int $optionPrice): static
  187.     {
  188.         $this->optionPrice $optionPrice;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection<int, Attribute>
  193.      */
  194.     public function getAttributes(): Collection
  195.     {
  196.         return $this->attributes;
  197.     }
  198.     public function addAttribute(Attribute $attribute): static
  199.     {
  200.         if (!$this->attributes->contains($attribute)) {
  201.             $this->attributes->add($attribute);
  202.             $attribute->addCart($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeAttribute(Attribute $attribute): static
  207.     {
  208.         if ($this->attributes->removeElement($attribute)) {
  209.             $attribute->removeCart($this);
  210.         }
  211.         return $this;
  212.     }
  213.     public function getAttributePrice(): ?int
  214.     {
  215.         return $this->attributePrice;
  216.     }
  217.     public function setAttributePrice(int $attributePrice): static
  218.     {
  219.         $this->attributePrice $attributePrice;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection<int, Sav>
  224.      */
  225.     public function getSavs(): Collection
  226.     {
  227.         return $this->savs;
  228.     }
  229.     public function addSav(Sav $sav): static
  230.     {
  231.         if (!$this->savs->contains($sav)) {
  232.             $this->savs->add($sav);
  233.             $sav->setCart($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeSav(Sav $sav): static
  238.     {
  239.         if ($this->savs->removeElement($sav)) {
  240.             // set the owning side to null (unless already changed)
  241.             if ($sav->getCart() === $this) {
  242.                 $sav->setCart(null);
  243.             }
  244.         }
  245.         return $this;
  246.     }
  247. }