src/Entity/Shop/Order/OrderItem.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Shop\Order;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Shop\Product\Product;
  5. use App\Entity\Shop\Product\ProductPrice;
  6. use App\Repository\Shop\Order\OrderItemRepository;
  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 Faker\Provider\Base;
  12. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  13. #[ORM\Entity(repositoryClassOrderItemRepository::class)]
  14. class OrderItem extends BaseEntity
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\Column(type'guid'uniquetrue)]
  18.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  19.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  20.     private ?string $id;
  21.     #[ORM\ManyToOne(inversedBy'orderItems')]
  22.     #[ORM\JoinColumn(nullablefalse)]
  23.     private ?Order $mainOrder null;
  24.     #[ORM\ManyToOne(inversedBy'orderItems')]
  25.     #[ORM\JoinColumn(nullablefalse)]
  26.     private ?Product $product null;
  27.     #[ORM\Column]
  28.     private ?int $quantity null;
  29.     #[ORM\Column(typeTypes::BIGINT)]
  30.     private ?string $price null;
  31.     #[ORM\OneToMany(mappedBy'orderItem'targetEntityOrderItemAttribute::class)]
  32.     private Collection $orderItemAttributes;
  33.     #[ORM\ManyToOne(inversedBy'orderItems')]
  34.     private ?ProductPrice $productPrice null;
  35.     public function __construct()
  36.     {
  37.         parent::__construct();
  38.         $this->orderItemAttributes = new ArrayCollection();
  39.     }
  40.     public function getId(): ?string
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getMainOrder(): ?Order
  45.     {
  46.         return $this->mainOrder;
  47.     }
  48.     public function setMainOrder(?Order $mainOrder): static
  49.     {
  50.         $this->mainOrder $mainOrder;
  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(): ?int
  63.     {
  64.         return $this->quantity;
  65.     }
  66.     public function setQuantity(int $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, OrderItemAttribute>
  82.      */
  83.     public function getOrderItemAttributes(): Collection
  84.     {
  85.         return $this->orderItemAttributes;
  86.     }
  87.     public function addOrderItemAttribute(OrderItemAttribute $orderItemAttribute): static
  88.     {
  89.         if (!$this->orderItemAttributes->contains($orderItemAttribute)) {
  90.             $this->orderItemAttributes->add($orderItemAttribute);
  91.             $orderItemAttribute->setOrderItem($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeOrderItemAttribute(OrderItemAttribute $orderItemAttribute): static
  96.     {
  97.         if ($this->orderItemAttributes->removeElement($orderItemAttribute)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($orderItemAttribute->getOrderItem() === $this) {
  100.                 $orderItemAttribute->setOrderItem(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     public function getProductPrice(): ?ProductPrice
  106.     {
  107.         return $this->productPrice;
  108.     }
  109.     public function setProductPrice(?ProductPrice $productPrice): static
  110.     {
  111.         $this->productPrice $productPrice;
  112.         return $this;
  113.     }
  114. }