src/Entity/Expediting/Repacking.php line 24

  1. <?php
  2. namespace App\Entity\Expediting;
  3. use ApiPlatform\Metadata\ApiProperty;
  4. use App\Doctrine\Type\Expediting\RepackingMotivation;
  5. use App\Entity\Common as Common;
  6. use App\Entity\Inventory\PackageMovement;
  7. use App\Validator\IsValidEnumArray\IsValidEnumArray;
  8. use DateTimeInterface;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Serializer\Annotation\Ignore;
  14. use Symfony\Component\Uid\Ulid;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. #[ORM\Table(name'expediting_repacking')]
  17. #[ORM\Index(columns: ['created_by'], name'expediting_repacking_created_by_idx')]
  18. #[ORM\Index(columns: ['updated_by'], name'expediting_repacking_updated_by_idx')]
  19. #[ORM\UniqueConstraint(name'expediting_repacking_identifier_key'columns: ['identifier'])]
  20. #[ORM\Entity]
  21. class Repacking
  22. {
  23.     use Common\Blameable;
  24.     use Common\Trackable;
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  27.     #[ORM\SequenceGenerator(sequenceName'expediting_repacking_id_seq')]
  28.     #[ORM\Column(typeTypes::INTEGER)]
  29.     #[ApiProperty(identifierfalse)]
  30.     private ?int $id null;
  31.     #[Assert\Ulid]
  32.     #[Assert\NotNull]
  33.     #[ORM\Column(type'ulid'uniquetrue)]
  34.     #[ApiProperty(identifiertrue)]
  35.     private ?Ulid $identifier null;
  36.     /** @var Collection<int, Package> */
  37.     #[ORM\OneToMany(mappedBy'destinationRepacking'targetEntityPackage::class)]
  38.     private Collection $inputs;
  39.     /** @var Collection<int, Package> */
  40.     #[ORM\OneToMany(mappedBy'sourceRepacking'targetEntityPackage::class)]
  41.     private Collection $outputs;
  42.     #[Assert\Type(typeDateTimeInterface::class)]
  43.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLEnullablefalse)]
  44.     private ?DateTimeInterface $completedAt null;
  45.     #[Assert\NotNull]
  46.     #[IsValidEnumArray(enumRepackingMotivation::class)]
  47.     #[ORM\Column(typeTypes::STRINGnullablefalseenumTypeRepackingMotivation::class)]
  48.     private ?RepackingMotivation $motivation null;
  49.     /** @var Collection<int, PackageMovement> */
  50.     #[ORM\OneToMany(mappedBy'repacking'targetEntityPackageMovement::class)]
  51.     #[Ignore]
  52.     private Collection $movements;
  53.     public function __construct()
  54.     {
  55.         $this->identifier = new Ulid();
  56.         $this->inputs = new ArrayCollection();
  57.         $this->outputs = new ArrayCollection();
  58.         $this->movements = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getIdentifier(): ?Ulid
  65.     {
  66.         return $this->identifier;
  67.     }
  68.     public function setIdentifier(Ulid $identifier): self
  69.     {
  70.         $this->identifier $identifier;
  71.         return $this;
  72.     }
  73.     public function getCompletedAt(): ?\DateTimeInterface
  74.     {
  75.         return $this->completedAt;
  76.     }
  77.     public function setCompletedAt(\DateTimeInterface $completedAt): static
  78.     {
  79.         $this->completedAt $completedAt;
  80.         return $this;
  81.     }
  82.     public function getMotivation(): ?RepackingMotivation
  83.     {
  84.         return $this->motivation;
  85.     }
  86.     public function setMotivation(RepackingMotivation $motivation): static
  87.     {
  88.         $this->motivation $motivation;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return Collection<int, Package>
  93.      */
  94.     public function getInputs(): Collection
  95.     {
  96.         return $this->inputs;
  97.     }
  98.     public function addInput(Package $input): static
  99.     {
  100.         if (!$this->inputs->contains($input)) {
  101.             $this->inputs->add($input);
  102.             $input->setDestinationRepacking($this);
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeInput(Package $input): static
  107.     {
  108.         if ($this->inputs->removeElement($input)) {
  109.             // set the owning side to null (unless already changed)
  110.             if ($input->getDestinationRepacking() === $this) {
  111.                 $input->setDestinationRepacking(null);
  112.             }
  113.         }
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, Package>
  118.      */
  119.     public function getOutputs(): Collection
  120.     {
  121.         return $this->outputs;
  122.     }
  123.     public function addOutput(Package $output): static
  124.     {
  125.         if (!$this->outputs->contains($output)) {
  126.             $this->outputs->add($output);
  127.             $output->setSourceRepacking($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeOutput(Package $output): static
  132.     {
  133.         if ($this->outputs->removeElement($output)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($output->getSourceRepacking() === $this) {
  136.                 $output->setSourceRepacking(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection<int, PackageMovement>
  143.      */
  144.     public function getMovements(): Collection
  145.     {
  146.         return $this->movements;
  147.     }
  148.     public function addMovement(PackageMovement $movement): static
  149.     {
  150.         if (!$this->movements->contains($movement)) {
  151.             $this->movements->add($movement);
  152.             $movement->setRepacking($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeMovement(PackageMovement $movement): static
  157.     {
  158.         if ($this->movements->removeElement($movement)) {
  159.             // set the owning side to null (unless already changed)
  160.             if ($movement->getRepacking() === $this) {
  161.                 $movement->setRepacking(null);
  162.             }
  163.         }
  164.         return $this;
  165.     }
  166. }