<?phpnamespace App\Entity;use App\Repository\WarehousesRepository;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=WarehousesRepository::class) */class Warehouses{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") * @Groups({ * "warehouse@core" * }) */ private $id; /** * @ORM\Column(type="string", length=64) * @Groups({ * "warehouse@core" * }) */ private $name; /** * @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="warehouses") * @ORM\JoinColumn(nullable=false) * @Groups({ * "warehouse@location" * }) */ private $location; /** * @ORM\ManyToOne(targetEntity=User::class, inversedBy="warehouses") * @ORM\JoinColumn(nullable=false) * @Groups({ * "warehouse@creator" * }) */ private $creator; /** * @ORM\Column(type="datetime_immutable") * @Groups({ * "warehouse@core" * }) */ private $created_at; /** * @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="warehouse") */ private $stocks; public function __construct() { $this->stocks = 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 getLocation(): ?Locations { return $this->location; } public function setLocation(?Locations $location): self { $this->location = $location; return $this; } public function getCreator(): ?User { return $this->creator; } public function setCreator(?User $creator): self { $this->creator = $creator; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->created_at; } public function setCreatedAt(\DateTimeImmutable $created_at): self { $this->created_at = $created_at; return $this; } /** * @return Collection<int, Stocks> */ public function getStocks(): Collection { return $this->stocks; } public function addStock(Stocks $stock): self { if (!$this->stocks->contains($stock)) { $this->stocks[] = $stock; $stock->setWarehouse($this); } return $this; } public function removeStock(Stocks $stock): self { if ($this->stocks->removeElement($stock)) { // set the owning side to null (unless already changed) if ($stock->getWarehouse() === $this) { $stock->setWarehouse(null); } } return $this; }}