src/Entity/Inventory/InventoryItemDisposal.php line 22
<?php
namespace App\Entity\Inventory;
use App\Doctrine\Type\Inventory\DisposalReason;
use App\Entity\Common as Common;
use App\Validator\IsValidEnum\IsValidEnum;
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: 'inventory_item_disposal')]
#[ORM\Index(columns: ['created_by'], name: 'inventory_item_disposal_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'inventory_item_disposal_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'inventory_item_disposal_identifier_key', columns: ['identifier'])]
#[ORM\Entity]
class InventoryItemDisposal
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'inventory_disposal_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[Assert\Ulid]
#[Assert\NotNull]
#[ORM\Column(type: 'ulid', unique: true)]
private ?Ulid $identifier = null;
#[Assert\NotNull]
#[IsValidEnum(enum: DisposalReason::class)]
#[ORM\Column(type: Types::STRING, enumType: DisposalReason::class)]
private ?DisposalReason $cause = null;
#[Assert\Type(type: DateTimeInterface::class)]
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE, nullable: false)]
private ?DateTimeInterface $completedAt = null;
/** @var Collection<int, ItemStockExit> */
#[ORM\OneToMany(mappedBy: 'disposal', targetEntity: ItemStockExit::class)]
#[Ignore]
private Collection $movements;
public function __construct()
{
$this->identifier = new Ulid();
$this->movements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdentifier(): ?Ulid
{
return $this->identifier;
}
public function setIdentifier(Ulid $identifier): static
{
$this->identifier = $identifier;
return $this;
}
public function getCause(): ?DisposalReason
{
return $this->cause;
}
public function setCause(DisposalReason $cause): static
{
$this->cause = $cause;
return $this;
}
public function getCompletedAt(): ?DateTimeInterface
{
return $this->completedAt;
}
public function setCompletedAt(DateTimeInterface $completedAt): static
{
$this->completedAt = $completedAt;
return $this;
}
/**
* @return Collection<int, ItemStockExit>
*/
public function getMovements(): Collection
{
return $this->movements;
}
public function addMovement(ItemStockExit $movement): static
{
if (!$this->movements->contains($movement)) {
$this->movements->add($movement);
$movement->setDisposal($this);
}
return $this;
}
public function removeMovement(ItemStockExit $movement): static
{
if ($this->movements->removeElement($movement)) {
// set the owning side to null (unless already changed)
if ($movement->getDisposal() === $this) {
$movement->setDisposal(null);
}
}
return $this;
}
}