<?phpnamespace App\Entity;use App\Repository\AttributeRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: AttributeRepository::class)]class Attribute{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 255)] private ?string $name = null; #[ORM\ManyToMany(targetEntity: Product::class, inversedBy: 'attributes')] private Collection $products; #[ORM\OneToMany(mappedBy: 'attribute', targetEntity: ProductExtra::class)] private Collection $productExtras; #[ORM\ManyToMany(targetEntity: OrderProduct::class, mappedBy: 'removeAttribute')] private Collection $orderProducts; public function __construct() { $this->products = new ArrayCollection(); $this->productExtras = new ArrayCollection(); $this->orderProducts = new ArrayCollection(); } public function __toString(): string { return $this->getId() . " - " . $this->getName(); } 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; } /** * @return Collection<int, Product> */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products[] = $product; } return $this; } public function removeProduct(Product $product): self { $this->products->removeElement($product); return $this; } /** * @return Collection<int, ProductExtra> */ public function getProductExtras(): Collection { return $this->productExtras; } public function addProductExtra(ProductExtra $productExtra): self { if (!$this->productExtras->contains($productExtra)) { $this->productExtras[] = $productExtra; $productExtra->setAttribute($this); } return $this; } public function removeProductExtra(ProductExtra $productExtra): self { if ($this->productExtras->removeElement($productExtra)) { if ($productExtra->getAttribute() === $this) { $productExtra->setAttribute(null); } } return $this; } /** * @return Collection<int, OrderProduct> */ public function getOrderProducts(): Collection { return $this->orderProducts; } public function addOrderProduct(OrderProduct $orderProduct): self { if (!$this->orderProducts->contains($orderProduct)) { $this->orderProducts[] = $orderProduct; $orderProduct->addRemoveAttribute($this); } return $this; } public function removeOrderProduct(OrderProduct $orderProduct): self { if ($this->orderProducts->removeElement($orderProduct)) { $orderProduct->removeRemoveAttribute($this); } return $this; }}