src/Entity/Delete/Container.php line 39

  1. <?php
  2. namespace App\Entity\Delete;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Link;
  6. use App\Doctrine\Type\Expediting\ContainerSize;
  7. use App\Doctrine\Type\Expediting\ContainerType;
  8. use App\Dto\Delete\ContainerInput;
  9. use App\Entity\Common as Common;
  10. use App\Processor\Delete\ContainerInputProcessor;
  11. use App\Validator\IsValidEnum\IsValidEnum;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\DBAL\Types\Types;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ORM\Table(name'expediting_z_container')]
  18. #[ORM\Index(columns: ['batch_id'], name'expediting_z_container_batch_id_idx')]
  19. #[ORM\Index(columns: ['created_by'], name'expediting_z_container_created_by_idx')]
  20. #[ORM\Index(columns: ['updated_by'], name'expediting_z_container_updated_by_idx')]
  21. #[ORM\UniqueConstraint(name'expediting_z_container_seal_number_key'columns: ['seal_number'])]
  22. #[ORM\Entity]
  23. #[ApiResource(
  24.     routePrefix'/xpediting',
  25.     inputContainerInput::class,
  26.     processorContainerInputProcessor::class,
  27. )]
  28. #[ApiResource(
  29.     uriTemplate'/batches/{slug}/containers',
  30.     operations: [new GetCollection()],
  31.     uriVariables: [
  32.         'slug' => new Link(fromProperty'containers'fromClassBatch::class),
  33.     ],
  34.     routePrefix'/xpediting',
  35. )]
  36. class Container
  37. {
  38.     use Common\Blameable;
  39.     use Common\Trackable;
  40.     #[ORM\Id]
  41.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  42.     #[ORM\SequenceGenerator(sequenceName'expediting_z_container_id_seq')]
  43.     #[ORM\Column(typeTypes::INTEGER)]
  44.     private ?int $id null;
  45.     #[ORM\ManyToOne(targetEntityBatch::class, inversedBy'containers')]
  46.     #[ORM\JoinColumn(name'batch_id')]
  47.     private ?Batch $batch null;
  48.     #[Assert\Type(typeTypes::STRING)]
  49.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  50.     private ?string $sealNumber null;
  51.     #[Assert\Type(typeTypes::STRING)]
  52.     #[ORM\Column(typeTypes::STRINGnullabletrue)]
  53.     private ?string $identificationNumber null;
  54.     #[IsValidEnum(enumContainerType::class)]
  55.     #[ORM\Column(typeTypes::STRINGenumTypeContainerType::class)]
  56.     private ?ContainerType $containerType null;
  57.     #[IsValidEnum(enumContainerSize::class)]
  58.     #[ORM\Column(typeTypes::STRINGenumTypeContainerSize::class)]
  59.     private ?ContainerSize $containerSize null;
  60.     #[Assert\Type(typeTypes::FLOAT)]
  61.     #[ORM\Column(typeTypes::DECIMALprecision18scale2nullabletrue)]
  62.     private ?float $tareWeight null;
  63.     #[Assert\Type(typeTypes::FLOAT)]
  64.     #[ORM\Column(typeTypes::DECIMALprecision18scale2nullabletrue)]
  65.     private ?float $grossWeight null;
  66.     #[Assert\Type(typeTypes::FLOAT)]
  67.     #[ORM\Column(typeTypes::DECIMALprecision18scale2nullabletrue)]
  68.     private ?float $volume null;
  69.     /** @var Collection<int, Box> */
  70.     #[ORM\OneToMany(mappedBy'container'targetEntityBox::class)]
  71.     private Collection $boxes;
  72.     public function __construct()
  73.     {
  74.         $this->boxes = new ArrayCollection();
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getSealNumber(): ?string
  81.     {
  82.         return $this->sealNumber;
  83.     }
  84.     public function setSealNumber(?string $sealNumber): static
  85.     {
  86.         $this->sealNumber = empty($sealNumber) ? null $sealNumber;
  87.         return $this;
  88.     }
  89.     public function getIdentificationNumber(): ?string
  90.     {
  91.         return $this->identificationNumber;
  92.     }
  93.     public function setIdentificationNumber(?string $identificationNumber): static
  94.     {
  95.         $this->identificationNumber $identificationNumber;
  96.         return $this;
  97.     }
  98.     public function getContainerType(): ?ContainerType
  99.     {
  100.         return $this->containerType;
  101.     }
  102.     public function setContainerType(?ContainerType $containerType): static
  103.     {
  104.         $this->containerType $containerType;
  105.         return $this;
  106.     }
  107.     public function getContainerSize(): ?ContainerSize
  108.     {
  109.         return $this->containerSize;
  110.     }
  111.     public function setContainerSize(?ContainerSize $containerSize): static
  112.     {
  113.         $this->containerSize $containerSize;
  114.         return $this;
  115.     }
  116.     public function getTareWeight(): ?float
  117.     {
  118.         return $this->tareWeight;
  119.     }
  120.     public function setTareWeight(?float $tareWeight): static
  121.     {
  122.         $this->tareWeight $tareWeight;
  123.         return $this;
  124.     }
  125.     public function getGrossWeight(): ?float
  126.     {
  127.         return $this->grossWeight;
  128.     }
  129.     public function setGrossWeight(?float $grossWeight): static
  130.     {
  131.         $this->grossWeight $grossWeight;
  132.         return $this;
  133.     }
  134.     public function getVolume(): ?float
  135.     {
  136.         return $this->volume;
  137.     }
  138.     public function setVolume(?float $volume): static
  139.     {
  140.         $this->volume $volume;
  141.         return $this;
  142.     }
  143.     public function getBatch(): ?Batch
  144.     {
  145.         return $this->batch;
  146.     }
  147.     public function setBatch(?Batch $batch): static
  148.     {
  149.         $this->batch $batch;
  150.         return $this;
  151.     }
  152.     /** @return Collection<int, Box> */
  153.     public function getBoxes(): Collection
  154.     {
  155.         return $this->boxes;
  156.     }
  157.     public function addBox(Box $box): static
  158.     {
  159.         if (!$this->boxes->contains($box)) {
  160.             $this->boxes->add($box);
  161.             $box->setContainer($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeBox(Box $box): static
  166.     {
  167.         if ($this->boxes->removeElement($box)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($box->getContainer() === $this) {
  170.                 $box->setContainer(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175. }