src/Entity/Expediting/Expeditable.php line 46
<?php
namespace App\Entity\Expediting;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use App\Doctrine\Type\Expediting\ExpeditableStatus;
use App\Entity\Common as Common;
use App\Entity\Common\Company;
use App\Entity\File\File;
use App\Entity\Sales\Asset;
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 Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'expediting_item')]
#[ORM\Index(columns: ['item_id'], name: 'expediting_item_item_id_idx')]
#[ORM\Index(columns: ['order_id'], name: 'expediting_item_order_id_idx')]
#[ORM\Index(columns: ['line_item_id'], name: 'expediting_item_line_item_id_idx')]
#[ORM\Index(columns: ['customer_id'], name: 'expediting_item_customer_id_idx')]
#[ORM\Index(columns: ['asset_id'], name: 'expediting_item_asset_id_idx')]
#[ORM\Index(columns: ['flow_id'], name: 'expediting_item_flow_id_idx')]
#[ORM\Index(columns: ['created_by'], name: 'expediting_item_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'expediting_item_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'expediting_item_slug_key', columns: ['slug'])]
#[ORM\UniqueConstraint(name: 'expediting_item_reference_key', columns: ['reference'])]
#[ORM\UniqueConstraint(name: 'expediting_item_identifier_key', columns: ['identifier'])]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'type', type: 'string')]
#[ORM\DiscriminatorMap([
'PART' => Part::class,
'ITEM' => Item::class,
'DOCUMENT' => Document::class,
])]
#[ORM\Entity]
#[UniqueEntity(fields: ['reference'])]
#[ApiFilter(SearchFilter::class, properties: [
'order.number' => 'ipartial',
])]
abstract class Expeditable
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'expediting_item_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
protected ?int $id = null;
#[Assert\Ulid]
#[Assert\NotNull]
#[ORM\Column(type: 'ulid', unique: true)]
protected ?Ulid $identifier = null;
#[Gedmo\Slug(fields: ['reference'])]
#[ORM\Column(type: Types::STRING)]
protected string $slug;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
protected ?string $reference = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
protected ?string $supplierDescription = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
protected ?string $clientDescription = null;
#[IsValidEnum(enum: ExpeditableStatus::class)]
#[ORM\Column(type: Types::STRING, enumType: ExpeditableStatus::class)]
protected ?ExpeditableStatus $status = null;
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: Company::class)]
#[ORM\JoinColumn(name: 'customer_id', nullable: false)]
protected ?Company $customer = null;
#[ORM\ManyToOne(targetEntity: Asset::class)]
#[ORM\JoinColumn(name: 'asset_id')]
protected ?Asset $asset = null;
/** @var Collection<int, Package> */
#[ORM\ManyToMany(targetEntity: Package::class, mappedBy: 'items', cascade: ['remove'])]
protected Collection $packages;
/** @var Collection<int, File> */
#[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist', 'remove'])]
#[ORM\JoinTable(name: 'expediting_item_file_map')]
#[ORM\JoinColumn(name: 'item_id')]
#[ORM\InverseJoinColumn(name: 'file_id')]
#[ORM\OrderBy(['id' => 'ASC'])]
private Collection $attachments;
public function __construct()
{
$this->identifier = new Ulid();
$this->packages = new ArrayCollection();
$this->attachments = 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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(?string $reference): self
{
$this->reference = $reference;
return $this;
}
public function getSupplierDescription(): ?string
{
return $this->supplierDescription;
}
public function setSupplierDescription(?string $supplierDescription): self
{
$this->supplierDescription = $supplierDescription;
return $this;
}
public function getClientDescription(): ?string
{
return $this->clientDescription;
}
public function setClientDescription(?string $clientDescription): self
{
$this->clientDescription = $clientDescription;
return $this;
}
public function getStatus(): ?ExpeditableStatus
{
return $this->status;
}
public function setStatus(?ExpeditableStatus $status): self
{
$this->status = $status;
return $this;
}
public function getCustomer(): ?Company
{
return $this->customer;
}
public function setCustomer(?Company $customer): self
{
$this->customer = $customer;
return $this;
}
public function getAsset(): ?Asset
{
return $this->asset;
}
public function setAsset(?Asset $asset): self
{
$this->asset = $asset;
return $this;
}
/**
* @return Collection<int, Package>
*/
public function getPackages(): Collection
{
return $this->packages;
}
public function addPackage(Package $package): self
{
if (!$this->packages->contains($package)) {
$this->packages->add($package);
$package->addItem($this);
}
return $this;
}
public function removePackage(Package $package): self
{
if ($this->packages->removeElement($package)) {
$package->removeItem($this);
}
return $this;
}
/**
* @return Collection<int, File>
*/
public function getAttachments(): Collection
{
return $this->attachments;
}
public function addAttachment(File $attachment): self
{
if (!$this->attachments->contains($attachment)) {
$this->attachments->add($attachment);
}
return $this;
}
public function removeAttachment(File $attachment): self
{
$this->attachments->removeElement($attachment);
return $this;
}
}