src/Entity/Expediting/Repacking.php line 24
<?php
namespace App\Entity\Expediting;
use ApiPlatform\Metadata\ApiProperty;
use App\Doctrine\Type\Expediting\RepackingMotivation;
use App\Entity\Common as Common;
use App\Entity\Inventory\PackageMovement;
use App\Validator\IsValidEnumArray\IsValidEnumArray;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'expediting_repacking')]
#[ORM\Index(columns: ['created_by'], name: 'expediting_repacking_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'expediting_repacking_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'expediting_repacking_identifier_key', columns: ['identifier'])]
#[ORM\Entity]
class Repacking
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'expediting_repacking_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
#[ApiProperty(identifier: false)]
private ?int $id = null;
#[Assert\Ulid]
#[Assert\NotNull]
#[ORM\Column(type: 'ulid', unique: true)]
#[ApiProperty(identifier: true)]
private ?Ulid $identifier = null;
/** @var Collection<int, Package> */
#[ORM\OneToMany(mappedBy: 'destinationRepacking', targetEntity: Package::class)]
private Collection $inputs;
/** @var Collection<int, Package> */
#[ORM\OneToMany(mappedBy: 'sourceRepacking', targetEntity: Package::class)]
private Collection $outputs;
#[Assert\Type(type: DateTimeInterface::class)]
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE, nullable: false)]
private ?DateTimeInterface $completedAt = null;
#[Assert\NotNull]
#[IsValidEnumArray(enum: RepackingMotivation::class)]
#[ORM\Column(type: Types::STRING, nullable: false, enumType: RepackingMotivation::class)]
private ?RepackingMotivation $motivation = null;
/** @var Collection<int, PackageMovement> */
#[ORM\OneToMany(mappedBy: 'repacking', targetEntity: PackageMovement::class)]
#[Ignore]
private Collection $movements;
public function __construct()
{
$this->identifier = new Ulid();
$this->inputs = new ArrayCollection();
$this->outputs = new ArrayCollection();
$this->movements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdentifier(): ?Ulid
{
return $this->identifier;
}
public function setIdentifier(Ulid $identifier): self
{
$this->identifier = $identifier;
return $this;
}
public function getCompletedAt(): ?\DateTimeInterface
{
return $this->completedAt;
}
public function setCompletedAt(\DateTimeInterface $completedAt): static
{
$this->completedAt = $completedAt;
return $this;
}
public function getMotivation(): ?RepackingMotivation
{
return $this->motivation;
}
public function setMotivation(RepackingMotivation $motivation): static
{
$this->motivation = $motivation;
return $this;
}
/**
* @return Collection<int, Package>
*/
public function getInputs(): Collection
{
return $this->inputs;
}
public function addInput(Package $input): static
{
if (!$this->inputs->contains($input)) {
$this->inputs->add($input);
$input->setDestinationRepacking($this);
}
return $this;
}
public function removeInput(Package $input): static
{
if ($this->inputs->removeElement($input)) {
// set the owning side to null (unless already changed)
if ($input->getDestinationRepacking() === $this) {
$input->setDestinationRepacking(null);
}
}
return $this;
}
/**
* @return Collection<int, Package>
*/
public function getOutputs(): Collection
{
return $this->outputs;
}
public function addOutput(Package $output): static
{
if (!$this->outputs->contains($output)) {
$this->outputs->add($output);
$output->setSourceRepacking($this);
}
return $this;
}
public function removeOutput(Package $output): static
{
if ($this->outputs->removeElement($output)) {
// set the owning side to null (unless already changed)
if ($output->getSourceRepacking() === $this) {
$output->setSourceRepacking(null);
}
}
return $this;
}
/**
* @return Collection<int, PackageMovement>
*/
public function getMovements(): Collection
{
return $this->movements;
}
public function addMovement(PackageMovement $movement): static
{
if (!$this->movements->contains($movement)) {
$this->movements->add($movement);
$movement->setRepacking($this);
}
return $this;
}
public function removeMovement(PackageMovement $movement): static
{
if ($this->movements->removeElement($movement)) {
// set the owning side to null (unless already changed)
if ($movement->getRepacking() === $this) {
$movement->setRepacking(null);
}
}
return $this;
}
}