src/Entity/Brand.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BrandRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * @ORM\Entity(repositoryClass=BrandRepository::class)
  10.  */
  11. class Brand
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups({"stock_edit", "installation_edit"})
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      * @Groups({"stock_edit"})
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\OneToMany(targetEntity=Stock::class, mappedBy="brand")
  27.      */
  28.     private $stocks;
  29.     /**
  30.      * @ORM\OneToMany(targetEntity=Reference::class, mappedBy="brand")
  31.      */
  32.     private $brand_references;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="brands")
  35.      * @Groups({"stock_edit"})
  36.      */
  37.     private $supplier;
  38.     public function __construct()
  39.     {
  40.         $this->stocks = new ArrayCollection();
  41.         $this->brand_references = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getName(): ?string
  48.     {
  49.         return $this->name;
  50.     }
  51.     public function setName(string $name): self
  52.     {
  53.         $this->name $name;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection<int, Stock>
  58.      */
  59.     public function getStocks(): Collection
  60.     {
  61.         return $this->stocks;
  62.     }
  63.     public function addStock(Stock $stock): self
  64.     {
  65.         if (!$this->stocks->contains($stock)) {
  66.             $this->stocks[] = $stock;
  67.             $stock->setBrand($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeStock(Stock $stock): self
  72.     {
  73.         if ($this->stocks->removeElement($stock)) {
  74.             // set the owning side to null (unless already changed)
  75.             if ($stock->getBrand() === $this) {
  76.                 $stock->setBrand(null);
  77.             }
  78.         }
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection<int, Reference>
  83.      */
  84.     public function getBrandReferences(): Collection
  85.     {
  86.         return $this->brand_references;
  87.     }
  88.     public function addBrandReference(Reference $brandReference): self
  89.     {
  90.         if (!$this->brand_references->contains($brandReference)) {
  91.             $this->brand_references[] = $brandReference;
  92.             $brandReference->setBrand($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeBrandReference(Reference $brandReference): self
  97.     {
  98.         if ($this->brand_references->removeElement($brandReference)) {
  99.             // set the owning side to null (unless already changed)
  100.             if ($brandReference->getBrand() === $this) {
  101.                 $brandReference->setBrand(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106.     public function getSupplier(): ?Supplier
  107.     {
  108.         return $this->supplier;
  109.     }
  110.     public function setSupplier(?Supplier $supplier): self
  111.     {
  112.         $this->supplier $supplier;
  113.         return $this;
  114.     }
  115. }