src/Entity/Delete/Container.php line 39
<?php
namespace App\Entity\Delete;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use App\Doctrine\Type\Expediting\ContainerSize;
use App\Doctrine\Type\Expediting\ContainerType;
use App\Dto\Delete\ContainerInput;
use App\Entity\Common as Common;
use App\Processor\Delete\ContainerInputProcessor;
use App\Validator\IsValidEnum\IsValidEnum;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'expediting_z_container')]
#[ORM\Index(columns: ['batch_id'], name: 'expediting_z_container_batch_id_idx')]
#[ORM\Index(columns: ['created_by'], name: 'expediting_z_container_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'expediting_z_container_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'expediting_z_container_seal_number_key', columns: ['seal_number'])]
#[ORM\Entity]
#[ApiResource(
routePrefix: '/xpediting',
input: ContainerInput::class,
processor: ContainerInputProcessor::class,
)]
#[ApiResource(
uriTemplate: '/batches/{slug}/containers',
operations: [new GetCollection()],
uriVariables: [
'slug' => new Link(fromProperty: 'containers', fromClass: Batch::class),
],
routePrefix: '/xpediting',
)]
class Container
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'expediting_z_container_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Batch::class, inversedBy: 'containers')]
#[ORM\JoinColumn(name: 'batch_id')]
private ?Batch $batch = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $sealNumber = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $identificationNumber = null;
#[IsValidEnum(enum: ContainerType::class)]
#[ORM\Column(type: Types::STRING, enumType: ContainerType::class)]
private ?ContainerType $containerType = null;
#[IsValidEnum(enum: ContainerSize::class)]
#[ORM\Column(type: Types::STRING, enumType: ContainerSize::class)]
private ?ContainerSize $containerSize = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 2, nullable: true)]
private ?float $tareWeight = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 2, nullable: true)]
private ?float $grossWeight = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 2, nullable: true)]
private ?float $volume = null;
/** @var Collection<int, Box> */
#[ORM\OneToMany(mappedBy: 'container', targetEntity: Box::class)]
private Collection $boxes;
public function __construct()
{
$this->boxes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSealNumber(): ?string
{
return $this->sealNumber;
}
public function setSealNumber(?string $sealNumber): static
{
$this->sealNumber = empty($sealNumber) ? null : $sealNumber;
return $this;
}
public function getIdentificationNumber(): ?string
{
return $this->identificationNumber;
}
public function setIdentificationNumber(?string $identificationNumber): static
{
$this->identificationNumber = $identificationNumber;
return $this;
}
public function getContainerType(): ?ContainerType
{
return $this->containerType;
}
public function setContainerType(?ContainerType $containerType): static
{
$this->containerType = $containerType;
return $this;
}
public function getContainerSize(): ?ContainerSize
{
return $this->containerSize;
}
public function setContainerSize(?ContainerSize $containerSize): static
{
$this->containerSize = $containerSize;
return $this;
}
public function getTareWeight(): ?float
{
return $this->tareWeight;
}
public function setTareWeight(?float $tareWeight): static
{
$this->tareWeight = $tareWeight;
return $this;
}
public function getGrossWeight(): ?float
{
return $this->grossWeight;
}
public function setGrossWeight(?float $grossWeight): static
{
$this->grossWeight = $grossWeight;
return $this;
}
public function getVolume(): ?float
{
return $this->volume;
}
public function setVolume(?float $volume): static
{
$this->volume = $volume;
return $this;
}
public function getBatch(): ?Batch
{
return $this->batch;
}
public function setBatch(?Batch $batch): static
{
$this->batch = $batch;
return $this;
}
/** @return Collection<int, Box> */
public function getBoxes(): Collection
{
return $this->boxes;
}
public function addBox(Box $box): static
{
if (!$this->boxes->contains($box)) {
$this->boxes->add($box);
$box->setContainer($this);
}
return $this;
}
public function removeBox(Box $box): static
{
if ($this->boxes->removeElement($box)) {
// set the owning side to null (unless already changed)
if ($box->getContainer() === $this) {
$box->setContainer(null);
}
}
return $this;
}
}