src/Entity/Delete/Quality/NonConformity.php line 62
<?php
namespace App\Entity\Delete\Quality;
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Doctrine\Type\Expediting\CasingMaterial;
use App\Doctrine\Type\Expediting\CasingType;
use App\Doctrine\Type\Expediting\NonConformityStatus;
use App\Doctrine\Type\Expediting\NonConformitySubject;
use App\Doctrine\Type\Expediting\NonConformityType;
use App\Dto\Delete\NcrInput;
use App\Entity\Common as Common;
use App\Entity\File\File;
use App\Entity\Identity\User;
use App\Processor\Delete\Quality\NcrInputProcessor;
use App\Provider\Delete\Quality\NonConformityProvider;
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\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'non_conformity')]
#[ORM\Entity]
#[ApiResource(
shortName: 'Ncr',
operations: [
new Get(provider: NonConformityProvider::class),
new GetCollection(),
new Post('/ncr', inputFormats: ['json' => ['application/json'], 'multipart' => ['multipart/form-data']]),
new Patch(),
new Put(),
new Delete(),
],
input: NcrInput::class,
processor: NcrInputProcessor::class,
)]
#[ApiFilter(SearchFilter::class, properties: [
'reference' => 'ipartial',
'subjectReference' => 'ipartial',
'invoicesNumbers' => 'ipartial',
'ordersNumbers' => 'ipartial',
'subjectType' => 'exact',
'status' => 'exact',
'type' => 'exact',
])]
#[ApiFilter(ExistsFilter::class, properties: [
'ncr',
])]
class NonConformity
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'expediting_z_box_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
#[ApiProperty(identifier: false)]
private int $id;
#[Gedmo\Slug(fields: ['reference'])]
#[ORM\Column(type: Types::STRING)]
#[ApiProperty(identifier: true)]
private ?string $slug = null;
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $reference = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $subjectReference = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $supplier = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $invoicesNumbers = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $ordersNumbers = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $lineItems = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $description = null;
#[Assert\Type(type: CasingType::class)]
#[IsValidEnum(enum: CasingType::class)]
#[ORM\Column(type: Types::STRING, nullable: true, enumType: CasingType::class)]
private ?CasingType $casingType = null;
#[Assert\Type(type: CasingMaterial::class)]
#[IsValidEnum(enum: CasingMaterial::class)]
#[ORM\Column(type: Types::STRING, nullable: true, enumType: CasingMaterial::class)]
private ?CasingMaterial $casingMaterial = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 3, nullable: true)]
private ?float $length = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 3, nullable: true)]
private ?float $width = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 3, nullable: true)]
private ?float $height = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 3, nullable: true)]
private ?float $weight = null;
#[Assert\Type(type: NonConformitySubject::class)]
#[IsValidEnum(enum: NonConformitySubject::class)]
#[ORM\Column(type: Types::STRING, enumType: NonConformitySubject::class)]
private ?NonConformitySubject $subjectType = null;
#[Assert\Type(type: NonConformityType::class)]
#[IsValidEnum(enum: NonConformityType::class)]
#[ORM\Column(type: Types::STRING, enumType: NonConformityType::class)]
private ?NonConformityType $type = null;
#[Assert\Type(type: NonConformityStatus::class)]
#[IsValidEnum(enum: NonConformityStatus::class)]
#[ORM\Column(type: Types::STRING, enumType: NonConformityStatus::class)]
private ?NonConformityStatus $status = null;
#[ORM\ManyToOne(targetEntity: NonConformity::class, inversedBy: 'boxes')]
#[ORM\JoinColumn(name: 'ncr_id', referencedColumnName: 'id')]
private ?NonConformity $ncr = null;
#[ORM\OneToMany(mappedBy: 'ncr', targetEntity: NonConformity::class)]
private Collection $boxes;
/** @var Collection<int, File> */
#[ORM\ManyToMany(targetEntity: File::class, cascade: ['persist', 'remove'])]
#[ORM\JoinTable(name: 'non_conformity_file_map')]
#[ORM\JoinColumn(name: 'non_conformity_id')]
#[ORM\InverseJoinColumn(name: 'file_id')]
#[ORM\OrderBy(['id' => 'ASC'])]
private Collection $images;
#[Gedmo\Blameable(on: 'create')]
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
protected ?User $createdBy = null;
public array $packages = [];
public array $pictures = [];
public function __construct()
{
$this->boxes = new ArrayCollection();
$this->images = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): static
{
$this->slug = $slug;
return $this;
}
public function getReference(): ?string
{
return $this->reference;
}
public function setReference(?string $reference): static
{
$this->reference = $reference;
return $this;
}
public function getSupplier(): ?string
{
return $this->supplier;
}
public function setSupplier(?string $supplier): static
{
$this->supplier = $supplier;
return $this;
}
public function getSubjectReference(): ?string
{
return $this->subjectReference;
}
public function setSubjectReference(?string $subjectReference): static
{
$this->subjectReference = $subjectReference;
return $this;
}
public function getInvoicesNumbers(): ?string
{
return $this->invoicesNumbers;
}
public function setInvoicesNumbers(?string $invoicesNumbers): static
{
$this->invoicesNumbers = $invoicesNumbers;
return $this;
}
public function getOrdersNumbers(): ?string
{
return $this->ordersNumbers;
}
public function setOrdersNumbers(?string $ordersNumbers): static
{
$this->ordersNumbers = $ordersNumbers;
return $this;
}
public function getLineItems(): ?string
{
return $this->lineItems;
}
public function setLineItems(?string $lineItems): static
{
$this->lineItems = $lineItems;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getCasingType(): ?CasingType
{
return $this->casingType;
}
public function setCasingType(?CasingType $casingType): static
{
$this->casingType = $casingType;
return $this;
}
public function getCasingMaterial(): ?CasingMaterial
{
return $this->casingMaterial;
}
public function setCasingMaterial(?CasingMaterial $casingMaterial): static
{
$this->casingMaterial = $casingMaterial;
return $this;
}
public function getLength(): ?float
{
return $this->length;
}
public function setLength(?float $length): static
{
$this->length = $length;
return $this;
}
public function getWidth(): ?float
{
return $this->width;
}
public function setWidth(?float $width): static
{
$this->width = $width;
return $this;
}
public function getHeight(): ?float
{
return $this->height;
}
public function setHeight(?float $height): static
{
$this->height = $height;
return $this;
}
public function getVolume(): ?float
{
return ($this->length * $this->width * $this->height) / 1_000_000;
}
public function getWeight(): ?float
{
return $this->weight;
}
public function setWeight(?float $weight): static
{
$this->weight = $weight;
return $this;
}
public function getSubjectType(): ?NonConformitySubject
{
return $this->subjectType;
}
public function setSubjectType(?NonConformitySubject $subjectType): static
{
$this->subjectType = $subjectType;
return $this;
}
public function getType(): ?NonConformityType
{
return $this->type;
}
public function setType(?NonConformityType $type): static
{
$this->type = $type;
return $this;
}
public function getStatus(): ?NonConformityStatus
{
return $this->status;
}
public function setStatus(?NonConformityStatus $status): static
{
$this->status = $status;
return $this;
}
public function getNcr(): ?self
{
return $this->ncr;
}
public function setNcr(?self $ncr): self
{
$this->ncr = $ncr;
return $this;
}
/**
* @return Collection<int, NonConformity>
*/
public function getBoxes(): Collection
{
return $this->boxes;
}
public function addBox(NonConformity $box): self
{
if (!$this->boxes->contains($box)) {
$this->boxes->add($box);
$box->setNcr($this);
}
return $this;
}
public function removeBox(NonConformity $box): self
{
if ($this->boxes->removeElement($box)) {
// set the owning side to null (unless already changed)
if ($box->getNcr() === $this) {
$box->setNcr(null);
}
}
return $this;
}
/**
* @return Collection<int, File>
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(File $image): self
{
if (!$this->images->contains($image)) {
$this->images->add($image);
}
return $this;
}
public function removeImage(File $image): self
{
$this->images->removeElement($image);
return $this;
}
}