src/Entity/Inventory/Warehouse.php line 17

  1. <?php
  2. namespace App\Entity\Inventory;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Entity\Common\Company;
  5. use App\Entity\Places\Facility;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Ignore;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. #[ORM\Entity]
  13. #[ApiResource(routePrefix'/places')]
  14. class Warehouse extends Facility
  15. {
  16.     #[Assert\NotNull]
  17.     #[ORM\Column(name'is_hub'typeTypes::BOOLEAN)]
  18.     private bool $hub false;
  19.     #[Assert\NotNull]
  20.     #[ORM\Column(name'is_managed'typeTypes::BOOLEAN)]
  21.     private bool $managed false;
  22.     #[ORM\ManyToOne(targetEntityCompany::class)]
  23.     #[ORM\JoinColumn(name'owner_id')]
  24.     private ?Company $owner null;
  25.     /** @var Collection<int, PackageMovement> */
  26.     #[ORM\OneToMany(mappedBy'warehouse'targetEntityPackageMovement::class)]
  27.     #[Ignore]
  28.     private Collection $movements;
  29.     /** @var Collection<int, InventoryItem> */
  30.     #[ORM\OneToMany(mappedBy'warehouse'targetEntityInventoryItem::class)]
  31.     private Collection $inventoriedItems;
  32.     /** @var Collection<int, Withdrawal> */
  33.     #[ORM\OneToMany(mappedBy'warehouse'targetEntityWithdrawal::class)]
  34.     private Collection $withdrawals;
  35.     public function __construct()
  36.     {
  37.         parent::__construct();
  38.         $this->movements = new ArrayCollection();
  39.         $this->inventoriedItems = new ArrayCollection();
  40.         $this->withdrawals = new ArrayCollection();
  41.     }
  42.     public function isHub(): bool
  43.     {
  44.         return $this->hub;
  45.     }
  46.     public function setHub(bool $hub): static
  47.     {
  48.         $this->hub $hub;
  49.         return $this;
  50.     }
  51.     public function isManaged(): bool
  52.     {
  53.         return $this->managed;
  54.     }
  55.     public function setManaged(bool $managed): static
  56.     {
  57.         $this->managed $managed;
  58.         return $this;
  59.     }
  60.     public function getOwner(): ?Company
  61.     {
  62.         return $this->owner;
  63.     }
  64.     public function setOwner(?Company $owner): static
  65.     {
  66.         $this->owner $owner;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @return Collection<int, PackageMovement>
  71.      */
  72.     public function getMovements(): Collection
  73.     {
  74.         return $this->movements;
  75.     }
  76.     public function addMovement(PackageMovement $movement): static
  77.     {
  78.         if (!$this->movements->contains($movement)) {
  79.             $this->movements->add($movement);
  80.             $movement->setWarehouse($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeMovement(PackageMovement $movement): static
  85.     {
  86.         if ($this->movements->removeElement($movement)) {
  87.             // set the owning side to null (unless already changed)
  88.             if ($movement->getWarehouse() === $this) {
  89.                 $movement->setWarehouse(null);
  90.             }
  91.         }
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return Collection<int, InventoryItem>
  96.      */
  97.     public function getInventoriedItems(): Collection
  98.     {
  99.         return $this->inventoriedItems;
  100.     }
  101.     public function addInventoriedItem(InventoryItem $inventoriedItem): static
  102.     {
  103.         if (!$this->inventoriedItems->contains($inventoriedItem)) {
  104.             $this->inventoriedItems->add($inventoriedItem);
  105.             $inventoriedItem->setWarehouse($this);
  106.         }
  107.         return $this;
  108.     }
  109.     public function removeInventoriedItem(InventoryItem $inventoriedItem): static
  110.     {
  111.         if ($this->inventoriedItems->removeElement($inventoriedItem)) {
  112.             // set the owning side to null (unless already changed)
  113.             if ($inventoriedItem->getWarehouse() === $this) {
  114.                 $inventoriedItem->setWarehouse(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection<int, Withdrawal>
  121.      */
  122.     public function getWithdrawals(): Collection
  123.     {
  124.         return $this->withdrawals;
  125.     }
  126.     public function addWithdrawal(Withdrawal $withdrawal): static
  127.     {
  128.         if (!$this->withdrawals->contains($withdrawal)) {
  129.             $this->withdrawals->add($withdrawal);
  130.             $withdrawal->setWarehouse($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeWithdrawal(Withdrawal $withdrawal): static
  135.     {
  136.         if ($this->withdrawals->removeElement($withdrawal)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($withdrawal->getWarehouse() === $this) {
  139.                 $withdrawal->setWarehouse(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144. }