<?php
namespace App\Entity;
use App\Repository\ItemGroupsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ItemGroupsRepository::class)
*/
class ItemGroups
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "item:group:core",
* "item_group@ref",
* "item_group@base",
* "item_group@core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=64)
* @Groups({
* "item:group:core",
* "item_group@base",
* "item_group@core"
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "item:group:core",
* "item_group@core"
* })
*/
private $description;
/**
* @ORM\OneToMany(targetEntity=StockItems::class, mappedBy="item_group")
*/
private $stockItems;
public function __construct()
{
$this->stockItems = new ArrayCollection();
}
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 getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, StockItems>
*/
public function getStockItems(): Collection
{
return $this->stockItems;
}
public function addStockItem(StockItems $stockItem): self
{
if (!$this->stockItems->contains($stockItem)) {
$this->stockItems[] = $stockItem;
$stockItem->setItemGroup($this);
}
return $this;
}
public function removeStockItem(StockItems $stockItem): self
{
if ($this->stockItems->removeElement($stockItem)) {
// set the owning side to null (unless already changed)
if ($stockItem->getItemGroup() === $this) {
$stockItem->setItemGroup(null);
}
}
return $this;
}
}