src/Entity/ProductExtra.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProductExtraRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassProductExtraRepository::class)]
  8. class ProductExtra
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private ?int $id null;
  14.     #[ORM\ManyToOne(targetEntityProduct::class, inversedBy'productExtras')]
  15.     private ?Product $product null;
  16.     #[ORM\ManyToOne(targetEntityAttribute::class, inversedBy'productExtras')]
  17.     private ?Attribute $attribute null;
  18.     #[ORM\Column(type'decimal'precision10scale2options: ['default' => 0.00])]
  19.     private ?string $extraPrice '0.00';
  20.     #[ORM\ManyToMany(targetEntityOrderProduct::class, mappedBy'extra')]
  21.     private Collection $orderProducts;
  22.     public function __construct()
  23.     {
  24.         $this->orderProducts = new ArrayCollection();
  25.     }
  26.     public function __toString(): string
  27.     {
  28.         return (string) $this->id " ";
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getProduct(): ?Product
  35.     {
  36.         return $this->product;
  37.     }
  38.     public function setProduct(?Product $product): self
  39.     {
  40.         $this->product $product;
  41.         return $this;
  42.     }
  43.     public function getAttribute(): ?Attribute
  44.     {
  45.         return $this->attribute;
  46.     }
  47.     public function setAttribute(?Attribute $attribute): self
  48.     {
  49.         $this->attribute $attribute;
  50.         return $this;
  51.     }
  52.     public function getAttributeName(): ?string
  53.     {
  54.         return $this->attribute?->getName();
  55.     }
  56.     public function getExtraPrice(): ?string
  57.     {
  58.         return $this->extraPrice;
  59.     }
  60.     public function setExtraPrice(?string $extraPrice): self
  61.     {
  62.         $this->extraPrice $extraPrice;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, OrderProduct>
  67.      */
  68.     public function getOrderProducts(): Collection
  69.     {
  70.         return $this->orderProducts;
  71.     }
  72.     public function addOrderProduct(OrderProduct $orderProduct): self
  73.     {
  74.         if (!$this->orderProducts->contains($orderProduct)) {
  75.             $this->orderProducts[] = $orderProduct;
  76.             $orderProduct->addExtra($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeOrderProduct(OrderProduct $orderProduct): self
  81.     {
  82.         if ($this->orderProducts->removeElement($orderProduct)) {
  83.             $orderProduct->removeExtra($this);
  84.         }
  85.         return $this;
  86.     }
  87. }