<?phpnamespace App\Entity;use App\Repository\ColorRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass=ColorRepository::class) */class Color{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string", length=128) */ private $name; /** * @ORM\Column(type="string", length=7, nullable=true) */ private $hex; /** * @ORM\Column(type="integer", nullable=true) */ private $wttId; /** * @ORM\OneToMany(targetEntity=Product::class, mappedBy="color") */ private $products; /** * @ORM\OneToMany(targetEntity=Stock::class, mappedBy="color") */ private $stocks; public function __construct() { $this->products = new ArrayCollection(); $this->stocks = new ArrayCollection(); } public function __toString() { return $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; } public function getHex(): ?string { return $this->hex; } public function setHex(?string $hex): self { $this->hex = $hex; return $this; } public function getWttId(): ?int { return $this->wttId; } public function setWttId(int $wttId): self { $this->wttId = $wttId; 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; $product->setColor($this); } return $this; } public function removeProduct(Product $product): self { if ($this->products->removeElement($product)) { // set the owning side to null (unless already changed) if ($product->getColor() === $this) { $product->setColor(null); } } return $this; } /** * @return Collection<int, Stock> */ public function getStocks(): Collection { return $this->stocks; } public function addStock(Stock $stock): self { if (!$this->stocks->contains($stock)) { $this->stocks[] = $stock; $stock->setColor($this); } return $this; } public function removeStock(Stock $stock): self { if ($this->stocks->removeElement($stock)) { // set the owning side to null (unless already changed) if ($stock->getColor() === $this) { $stock->setColor(null); } } return $this; }}