<?phpnamespace App\Entity;use App\Repository\OrderProductRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: OrderProductRepository::class)]class OrderProduct{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 255)] private string $name; #[ORM\Column(type: 'float')] private float $price; #[ORM\Column(type: 'integer')] private int $quantity; #[ORM\ManyToOne(targetEntity: Order::class, inversedBy: 'orderProducts')] #[ORM\JoinColumn(nullable: true)] private ?Order $orderRelation = null; #[ORM\ManyToMany(targetEntity: Attribute::class, inversedBy: 'orderProducts')] private Collection $removeAttribute; #[ORM\ManyToMany(targetEntity: ProductExtra::class, inversedBy: 'orderProducts')] private Collection $extra; #[ORM\ManyToOne(inversedBy: 'orderProducts')] private ?Product $product = null; public function __construct() { $this->removeAttribute = new ArrayCollection(); $this->extra = new ArrayCollection(); } public function __toString(): string { return $this->name ?? 'N/A'; } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getPrice(): ?float { return $this->price; } public function setPrice(float $price): self { $this->price = $price; return $this; } public function getQuantity(): ?int { return $this->quantity; } public function setQuantity(int $quantity): self { $this->quantity = $quantity; return $this; } public function getOrderRelation(): ?Order { return $this->orderRelation; } public function setOrderRelation(?Order $orderRelation): self { $this->orderRelation = $orderRelation; return $this; } /** * @return Collection<int, Attribute> */ public function getRemoveAttribute(): Collection { return $this->removeAttribute; } public function addRemoveAttribute(Attribute $removeAttribute): self { if (!$this->removeAttribute->contains($removeAttribute)) { $this->removeAttribute[] = $removeAttribute; } return $this; } public function removeRemoveAttribute(Attribute $removeAttribute): self { $this->removeAttribute->removeElement($removeAttribute); return $this; } /** * @return Collection<int, ProductExtra> */ public function getExtra(): Collection { return $this->extra; } public function addExtra(ProductExtra $extra): self { if (!$this->extra->contains($extra)) { $this->extra[] = $extra; } return $this; } public function removeExtra(ProductExtra $extra): self { $this->extra->removeElement($extra); return $this; } public function getProduct(): ?Product { return $this->product; } public function setProduct(?Product $product): static { $this->product = $product; return $this; }}