src/Entity/OrderProduct.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderProductRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassOrderProductRepository::class)]
  8. class OrderProduct
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private ?int $id null;
  14.     #[ORM\Column(type'string'length255)]
  15.     private string $name;
  16.     #[ORM\Column(type'float')]
  17.     private float $price;
  18.     #[ORM\Column(type'integer')]
  19.     private int $quantity;
  20.     #[ORM\ManyToOne(targetEntityOrder::class, inversedBy'orderProducts')]
  21.     #[ORM\JoinColumn(nullabletrue)]
  22.     private ?Order $orderRelation null;
  23.     #[ORM\ManyToMany(targetEntityAttribute::class, inversedBy'orderProducts')]
  24.     private Collection $removeAttribute;
  25.     #[ORM\ManyToMany(targetEntityProductExtra::class, inversedBy'orderProducts')]
  26.     private Collection $extra;
  27.     #[ORM\ManyToOne(inversedBy'orderProducts')]
  28.     private ?Product $product null;
  29.     public function __construct()
  30.     {
  31.         $this->removeAttribute = new ArrayCollection();
  32.         $this->extra = new ArrayCollection();
  33.     }
  34.     public function __toString(): string
  35.     {
  36.         return $this->name ?? 'N/A';
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getName(): ?string
  43.     {
  44.         return $this->name;
  45.     }
  46.     public function setName(string $name): self
  47.     {
  48.         $this->name $name;
  49.         return $this;
  50.     }
  51.     public function getPrice(): ?float
  52.     {
  53.         return $this->price;
  54.     }
  55.     public function setPrice(float $price): self
  56.     {
  57.         $this->price $price;
  58.         return $this;
  59.     }
  60.     public function getQuantity(): ?int
  61.     {
  62.         return $this->quantity;
  63.     }
  64.     public function setQuantity(int $quantity): self
  65.     {
  66.         $this->quantity $quantity;
  67.         return $this;
  68.     }
  69.     public function getOrderRelation(): ?Order
  70.     {
  71.         return $this->orderRelation;
  72.     }
  73.     public function setOrderRelation(?Order $orderRelation): self
  74.     {
  75.         $this->orderRelation $orderRelation;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection<int, Attribute>
  80.      */
  81.     public function getRemoveAttribute(): Collection
  82.     {
  83.         return $this->removeAttribute;
  84.     }
  85.     public function addRemoveAttribute(Attribute $removeAttribute): self
  86.     {
  87.         if (!$this->removeAttribute->contains($removeAttribute)) {
  88.             $this->removeAttribute[] = $removeAttribute;
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeRemoveAttribute(Attribute $removeAttribute): self
  93.     {
  94.         $this->removeAttribute->removeElement($removeAttribute);
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection<int, ProductExtra>
  99.      */
  100.     public function getExtra(): Collection
  101.     {
  102.         return $this->extra;
  103.     }
  104.     public function addExtra(ProductExtra $extra): self
  105.     {
  106.         if (!$this->extra->contains($extra)) {
  107.             $this->extra[] = $extra;
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeExtra(ProductExtra $extra): self
  112.     {
  113.         $this->extra->removeElement($extra);
  114.         return $this;
  115.     }
  116.     public function getProduct(): ?Product
  117.     {
  118.         return $this->product;
  119.     }
  120.     public function setProduct(?Product $product): static
  121.     {
  122.         $this->product $product;
  123.         return $this;
  124.     }
  125. }