src/Entity/Shop/Cart/CartItem.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Cart;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Product\Product;
  5. use App\Entity\Shop\Shop\Shop;
  6. use App\Repository\Shop\Cart\CartItemRepository;
  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. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  12. #[ORM\Entity(repositoryClassCartItemRepository::class)]
  13. class CartItem extends BaseEntity
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\Column(type'guid'uniquetrue)]
  17.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  18.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  19.     private ?string $id;
  20.     #[ORM\ManyToOne(inversedBy'cartItems')]
  21.     #[ORM\JoinColumn(nullablefalse)]
  22.     private ?Cart $cart null;
  23.     #[ORM\ManyToOne(inversedBy'cartItems')]
  24.     #[ORM\JoinColumn(nullablefalse)]
  25.     private ?Product $product null;
  26.     #[ORM\Column(typeTypes::BIGINT)]
  27.     private ?string $quantity null;
  28.     #[ORM\Column(typeTypes::BIGINT)]
  29.     private ?string $price null;
  30.     #[ORM\OneToMany(mappedBy'cartItem'targetEntityCartItemAttribute::class)]
  31.     private Collection $cartItemAttributes;
  32.     #[ORM\ManyToOne(inversedBy'cartItems')]
  33.     #[ORM\JoinColumn(nullablefalse)]
  34.     private ?Shop $shop null;
  35.     public function __construct()
  36.     {
  37.         parent::__construct();
  38.         $this->cartItemAttributes = new ArrayCollection();
  39.     }
  40.     public function getId(): ?string
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getCart(): ?Cart
  45.     {
  46.         return $this->cart;
  47.     }
  48.     public function setCart(?Cart $cart): static
  49.     {
  50.         $this->cart $cart;
  51.         return $this;
  52.     }
  53.     public function getProduct(): ?Product
  54.     {
  55.         return $this->product;
  56.     }
  57.     public function setProduct(?Product $product): static
  58.     {
  59.         $this->product $product;
  60.         return $this;
  61.     }
  62.     public function getQuantity(): ?string
  63.     {
  64.         return $this->quantity;
  65.     }
  66.     public function setQuantity(string $quantity): static
  67.     {
  68.         $this->quantity $quantity;
  69.         return $this;
  70.     }
  71.     public function getPrice(): ?string
  72.     {
  73.         return $this->price;
  74.     }
  75.     public function setPrice(string $price): static
  76.     {
  77.         $this->price $price;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, CartItemAttribute>
  82.      */
  83.     public function getCartItemAttributes(): Collection
  84.     {
  85.         return $this->cartItemAttributes;
  86.     }
  87.     public function addCartItemAttribute(CartItemAttribute $cartItemAttribute): static
  88.     {
  89.         if (!$this->cartItemAttributes->contains($cartItemAttribute)) {
  90.             $this->cartItemAttributes->add($cartItemAttribute);
  91.             $cartItemAttribute->setCartItem($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeCartItemAttribute(CartItemAttribute $cartItemAttribute): static
  96.     {
  97.         if ($this->cartItemAttributes->removeElement($cartItemAttribute)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($cartItemAttribute->getCartItem() === $this) {
  100.                 $cartItemAttribute->setCartItem(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     public function getShop(): ?Shop
  106.     {
  107.         return $this->shop;
  108.     }
  109.     public function setShop(?Shop $shop): static
  110.     {
  111.         $this->shop $shop;
  112.         return $this;
  113.     }
  114. }