src/Entity/Inventory/Warehouse.php line 17
<?php
namespace App\Entity\Inventory;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Common\Company;
use App\Entity\Places\Facility;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity]
#[ApiResource(routePrefix: '/places')]
class Warehouse extends Facility
{
#[Assert\NotNull]
#[ORM\Column(name: 'is_hub', type: Types::BOOLEAN)]
private bool $hub = false;
#[Assert\NotNull]
#[ORM\Column(name: 'is_managed', type: Types::BOOLEAN)]
private bool $managed = false;
#[ORM\ManyToOne(targetEntity: Company::class)]
#[ORM\JoinColumn(name: 'owner_id')]
private ?Company $owner = null;
/** @var Collection<int, PackageMovement> */
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: PackageMovement::class)]
#[Ignore]
private Collection $movements;
/** @var Collection<int, InventoryItem> */
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: InventoryItem::class)]
private Collection $inventoriedItems;
/** @var Collection<int, Withdrawal> */
#[ORM\OneToMany(mappedBy: 'warehouse', targetEntity: Withdrawal::class)]
private Collection $withdrawals;
public function __construct()
{
parent::__construct();
$this->movements = new ArrayCollection();
$this->inventoriedItems = new ArrayCollection();
$this->withdrawals = new ArrayCollection();
}
public function isHub(): bool
{
return $this->hub;
}
public function setHub(bool $hub): static
{
$this->hub = $hub;
return $this;
}
public function isManaged(): bool
{
return $this->managed;
}
public function setManaged(bool $managed): static
{
$this->managed = $managed;
return $this;
}
public function getOwner(): ?Company
{
return $this->owner;
}
public function setOwner(?Company $owner): static
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection<int, PackageMovement>
*/
public function getMovements(): Collection
{
return $this->movements;
}
public function addMovement(PackageMovement $movement): static
{
if (!$this->movements->contains($movement)) {
$this->movements->add($movement);
$movement->setWarehouse($this);
}
return $this;
}
public function removeMovement(PackageMovement $movement): static
{
if ($this->movements->removeElement($movement)) {
// set the owning side to null (unless already changed)
if ($movement->getWarehouse() === $this) {
$movement->setWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, InventoryItem>
*/
public function getInventoriedItems(): Collection
{
return $this->inventoriedItems;
}
public function addInventoriedItem(InventoryItem $inventoriedItem): static
{
if (!$this->inventoriedItems->contains($inventoriedItem)) {
$this->inventoriedItems->add($inventoriedItem);
$inventoriedItem->setWarehouse($this);
}
return $this;
}
public function removeInventoriedItem(InventoryItem $inventoriedItem): static
{
if ($this->inventoriedItems->removeElement($inventoriedItem)) {
// set the owning side to null (unless already changed)
if ($inventoriedItem->getWarehouse() === $this) {
$inventoriedItem->setWarehouse(null);
}
}
return $this;
}
/**
* @return Collection<int, Withdrawal>
*/
public function getWithdrawals(): Collection
{
return $this->withdrawals;
}
public function addWithdrawal(Withdrawal $withdrawal): static
{
if (!$this->withdrawals->contains($withdrawal)) {
$this->withdrawals->add($withdrawal);
$withdrawal->setWarehouse($this);
}
return $this;
}
public function removeWithdrawal(Withdrawal $withdrawal): static
{
if ($this->withdrawals->removeElement($withdrawal)) {
// set the owning side to null (unless already changed)
if ($withdrawal->getWarehouse() === $this) {
$withdrawal->setWarehouse(null);
}
}
return $this;
}
}