src/Entity/Color.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ColorRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ColorRepository::class)
  9.  */
  10. class Color
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=128)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="string", length=7, nullable=true)
  24.      */
  25.     private $hex;
  26.     /**
  27.      * @ORM\Column(type="integer", nullable=true)
  28.      */
  29.     private $wttId;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=Product::class, mappedBy="color")
  32.      */
  33.     private $products;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity=Stock::class, mappedBy="color")
  36.      */
  37.     private $stocks;
  38.     public function __construct()
  39.     {
  40.         $this->products = new ArrayCollection();
  41.         $this->stocks = new ArrayCollection();
  42.     }
  43.     public function __toString()
  44.     {
  45.         return $this->getName();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getName(): ?string
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function setName(string $name): self
  56.     {
  57.         $this->name $name;
  58.         return $this;
  59.     }
  60.     public function getHex(): ?string
  61.     {
  62.         return $this->hex;
  63.     }
  64.     public function setHex(?string $hex): self
  65.     {
  66.         $this->hex $hex;
  67.         return $this;
  68.     }
  69.     public function getWttId(): ?int
  70.     {
  71.         return $this->wttId;
  72.     }
  73.     public function setWttId(int $wttId): self
  74.     {
  75.         $this->wttId $wttId;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection<int, Product>
  80.      */
  81.     public function getProducts(): Collection
  82.     {
  83.         return $this->products;
  84.     }
  85.     public function addProduct(Product $product): self
  86.     {
  87.         if (!$this->products->contains($product)) {
  88.             $this->products[] = $product;
  89.             $product->setColor($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeProduct(Product $product): self
  94.     {
  95.         if ($this->products->removeElement($product)) {
  96.             // set the owning side to null (unless already changed)
  97.             if ($product->getColor() === $this) {
  98.                 $product->setColor(null);
  99.             }
  100.         }
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, Stock>
  105.      */
  106.     public function getStocks(): Collection
  107.     {
  108.         return $this->stocks;
  109.     }
  110.     public function addStock(Stock $stock): self
  111.     {
  112.         if (!$this->stocks->contains($stock)) {
  113.             $this->stocks[] = $stock;
  114.             $stock->setColor($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removeStock(Stock $stock): self
  119.     {
  120.         if ($this->stocks->removeElement($stock)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($stock->getColor() === $this) {
  123.                 $stock->setColor(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128. }