src/Entity/ItemGroups.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ItemGroupsRepository;
  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=ItemGroupsRepository::class)
  10.  */
  11. class ItemGroups
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      * @Groups({
  18.      *     "item:group:core",
  19.      *     "item_group@ref",
  20.      *     "item_group@base",
  21.      *     "item_group@core"
  22.      * })
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=64)
  27.      * @Groups({
  28.      *      "item:group:core",
  29.      *      "item_group@base",
  30.      *      "item_group@core"
  31.      *  })
  32.      */
  33.     private $name;
  34.     /**
  35.      * @ORM\Column(type="string", length=64, nullable=true)
  36.      * @Groups({
  37.      *      "item:group:core",
  38.      *      "item_group@core"
  39.      *  })
  40.      */
  41.     private $description;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=StockItems::class, mappedBy="item_group")
  44.      */
  45.     private $stockItems;
  46.     public function __construct()
  47.     {
  48.         $this->stockItems = new ArrayCollection();
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): self
  59.     {
  60.         $this->name = $name;
  61.         return $this;
  62.     }
  63.     public function getDescription(): ?string
  64.     {
  65.         return $this->description;
  66.     }
  67.     public function setDescription(?string $description): self
  68.     {
  69.         $this->description = $description;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, StockItems>
  74.      */
  75.     public function getStockItems(): Collection
  76.     {
  77.         return $this->stockItems;
  78.     }
  79.     public function addStockItem(StockItems $stockItem): self
  80.     {
  81.         if (!$this->stockItems->contains($stockItem)) {
  82.             $this->stockItems[] = $stockItem;
  83.             $stockItem->setItemGroup($this);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeStockItem(StockItems $stockItem): self
  88.     {
  89.         if ($this->stockItems->removeElement($stockItem)) {
  90.             // set the owning side to null (unless already changed)
  91.             if ($stockItem->getItemGroup() === $this) {
  92.                 $stockItem->setItemGroup(null);
  93.             }
  94.         }
  95.         return $this;
  96.     }
  97. }