src/Entity/Inventory/InventoryItemDisposal.php line 22

  1. <?php
  2. namespace App\Entity\Inventory;
  3. use App\Doctrine\Type\Inventory\DisposalReason;
  4. use App\Entity\Common as Common;
  5. use App\Validator\IsValidEnum\IsValidEnum;
  6. use DateTimeInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Ignore;
  12. use Symfony\Component\Uid\Ulid;
  13. use Symfony\Component\Validator\Constraints as Assert;
  14. #[ORM\Table(name'inventory_item_disposal')]
  15. #[ORM\Index(columns: ['created_by'], name'inventory_item_disposal_created_by_idx')]
  16. #[ORM\Index(columns: ['updated_by'], name'inventory_item_disposal_updated_by_idx')]
  17. #[ORM\UniqueConstraint(name'inventory_item_disposal_identifier_key'columns: ['identifier'])]
  18. #[ORM\Entity]
  19. class InventoryItemDisposal
  20. {
  21.     use Common\Blameable;
  22.     use Common\Trackable;
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  25.     #[ORM\SequenceGenerator(sequenceName'inventory_disposal_id_seq')]
  26.     #[ORM\Column(typeTypes::INTEGER)]
  27.     private ?int $id null;
  28.     #[Assert\Ulid]
  29.     #[Assert\NotNull]
  30.     #[ORM\Column(type'ulid'uniquetrue)]
  31.     private ?Ulid $identifier null;
  32.     #[Assert\NotNull]
  33.     #[IsValidEnum(enumDisposalReason::class)]
  34.     #[ORM\Column(typeTypes::STRINGenumTypeDisposalReason::class)]
  35.     private ?DisposalReason $cause null;
  36.     #[Assert\Type(typeDateTimeInterface::class)]
  37.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLEnullablefalse)]
  38.     private ?DateTimeInterface $completedAt null;
  39.     /** @var Collection<int, ItemStockExit> */
  40.     #[ORM\OneToMany(mappedBy'disposal'targetEntityItemStockExit::class)]
  41.     #[Ignore]
  42.     private Collection $movements;
  43.     public function __construct()
  44.     {
  45.         $this->identifier = new Ulid();
  46.         $this->movements = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getIdentifier(): ?Ulid
  53.     {
  54.         return $this->identifier;
  55.     }
  56.     public function setIdentifier(Ulid $identifier): static
  57.     {
  58.         $this->identifier $identifier;
  59.         return $this;
  60.     }
  61.     public function getCause(): ?DisposalReason
  62.     {
  63.         return $this->cause;
  64.     }
  65.     public function setCause(DisposalReason $cause): static
  66.     {
  67.         $this->cause $cause;
  68.         return $this;
  69.     }
  70.     public function getCompletedAt(): ?DateTimeInterface
  71.     {
  72.         return $this->completedAt;
  73.     }
  74.     public function setCompletedAt(DateTimeInterface $completedAt): static
  75.     {
  76.         $this->completedAt $completedAt;
  77.         return $this;
  78.     }
  79.     /**
  80.      * @return Collection<int, ItemStockExit>
  81.      */
  82.     public function getMovements(): Collection
  83.     {
  84.         return $this->movements;
  85.     }
  86.     public function addMovement(ItemStockExit $movement): static
  87.     {
  88.         if (!$this->movements->contains($movement)) {
  89.             $this->movements->add($movement);
  90.             $movement->setDisposal($this);
  91.         }
  92.         return $this;
  93.     }
  94.     public function removeMovement(ItemStockExit $movement): static
  95.     {
  96.         if ($this->movements->removeElement($movement)) {
  97.             // set the owning side to null (unless already changed)
  98.             if ($movement->getDisposal() === $this) {
  99.                 $movement->setDisposal(null);
  100.             }
  101.         }
  102.         return $this;
  103.     }
  104. }