src/Entity/Inventory/InventoryItemUnitization.php line 19

  1. <?php
  2. namespace App\Entity\Inventory;
  3. use App\Entity\Common as Common;
  4. use DateTimeInterface;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Uid\Ulid;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Table(name'inventory_item_unitization')]
  12. #[ORM\Index(columns: ['created_by'], name'inventory_item_unitization_created_by_idx')]
  13. #[ORM\Index(columns: ['updated_by'], name'inventory_item_unitization_updated_by_idx')]
  14. #[ORM\UniqueConstraint(name'inventory_item_unitization_identifier_key'columns: ['identifier'])]
  15. #[ORM\Entity]
  16. class InventoryItemUnitization
  17. {
  18.     use Common\Blameable;
  19.     use Common\Trackable;
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  22.     #[ORM\SequenceGenerator(sequenceName'inventory_item_unitization_id_seq')]
  23.     #[ORM\Column(typeTypes::INTEGER)]
  24.     private ?int $id null;
  25.     #[Assert\Ulid]
  26.     #[Assert\NotNull]
  27.     #[ORM\Column(type'ulid'uniquetrue)]
  28.     private ?Ulid $identifier null;
  29.     #[Assert\Type(typeDateTimeInterface::class)]
  30.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLEnullablefalse)]
  31.     private ?DateTimeInterface $completedAt null;
  32.     /** @var Collection<int, ItemStockExit> */
  33.     #[ORM\OneToMany(mappedBy'destinationUnitization'targetEntityItemStockExit::class)]
  34.     private Collection $inputs;
  35.     /** @var Collection<int, ItemStockEntry> */
  36.     #[ORM\OneToMany(mappedBy'sourceUnitization'targetEntityItemStockEntry::class)]
  37.     private Collection $outputs;
  38.     public function __construct()
  39.     {
  40.         $this->identifier = new Ulid();
  41.         $this->inputs = new ArrayCollection();
  42.         $this->outputs = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getIdentifier(): ?Ulid
  49.     {
  50.         return $this->identifier;
  51.     }
  52.     public function setIdentifier(Ulid $identifier): static
  53.     {
  54.         $this->identifier $identifier;
  55.         return $this;
  56.     }
  57.     public function getCompletedAt(): ?\DateTimeInterface
  58.     {
  59.         return $this->completedAt;
  60.     }
  61.     public function setCompletedAt(\DateTimeInterface $completedAt): static
  62.     {
  63.         $this->completedAt $completedAt;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @return Collection<int, ItemStockExit>
  68.      */
  69.     public function getInputs(): Collection
  70.     {
  71.         return $this->inputs;
  72.     }
  73.     public function addInput(ItemStockExit $input): static
  74.     {
  75.         if (!$this->inputs->contains($input)) {
  76.             $this->inputs->add($input);
  77.             $input->setDestinationUnitization($this);
  78.         }
  79.         return $this;
  80.     }
  81.     public function removeInput(ItemStockExit $input): static
  82.     {
  83.         if ($this->inputs->removeElement($input)) {
  84.             // set the owning side to null (unless already changed)
  85.             if ($input->getDestinationUnitization() === $this) {
  86.                 $input->setDestinationUnitization(null);
  87.             }
  88.         }
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, ItemStockEntry>
  93.      */
  94.     public function getOutputs(): Collection
  95.     {
  96.         return $this->outputs;
  97.     }
  98.     public function addOutput(ItemStockEntry $output): static
  99.     {
  100.         if (!$this->outputs->contains($output)) {
  101.             $this->outputs->add($output);
  102.             $output->setSourceUnitization($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeOutput(ItemStockEntry $output): static
  107.     {
  108.         if ($this->outputs->removeElement($output)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($output->getSourceUnitization() === $this) {
  111.                 $output->setSourceUnitization(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116. }