src/Entity/Delete/Material.php line 32
<?php
namespace App\Entity\Delete;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use App\Entity\Common as Common;
use App\Entity\Identity\User;
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: 'inventory_x_material')]
#[ORM\Index(columns: ['created_by'], name: 'inventory_x_material_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'inventory_x_material_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'inventory_x_material_slug_key', columns: ['slug'])]
#[ORM\Entity]
#[ApiResource(
routePrefix: '/nventory',
)]
#[ApiFilter(SearchFilter::class, properties: [
'searchable' => 'ipartial',
'orderNumber' => 'ipartial',
'materialNumber' => 'ipartial',
'description' => 'ipartial',
])]
class Material
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'inventory_x_material_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
#[ApiProperty(identifier: false)]
private int $id;
#[Gedmo\Slug(fields: ['orderNumber', 'materialNumber'])]
#[ORM\Column(type: Types::STRING)]
#[ApiProperty(identifier: true)]
private string $slug;
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $orderNumber = null;
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $itemNumber = null;
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $materialNumber = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $supplierPartNumber = null;
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $description = null;
#[Assert\NotBlank]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $supplier = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $owner = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $preservation = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $searchable = null;
#[Assert\NotNull]
#[Assert\Type(type: Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $quantity = null;
#[Assert\NotNull]
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 2)]
private ?float $unitPrice = null;
#[Assert\NotNull]
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 2)]
private ?float $value = null;
#[Assert\Length(exactly: 3)]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, length: 3, nullable: true)]
private ?string $currency = null;
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING, nullable: true)]
private ?string $spfr = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $degrouped = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $certified = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private ?bool $fatRequired = false;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private ?bool $retired = false;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $expeditable = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $dangerous = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, nullable: true)]
private ?bool $prohibited = null;
#[Gedmo\Blameable(on: 'create')]
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
protected ?User $createdBy = null;
/** @var Collection<int, Movement> */
#[ORM\OneToMany(mappedBy: 'material', targetEntity: Movement::class, cascade: ['persist', 'remove'])]
private Collection $movements;
public function __construct()
{
$this->movements = 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 getOrderNumber(): ?string
{
return $this->orderNumber;
}
public function setOrderNumber(string $orderNumber): static
{
$this->orderNumber = $orderNumber;
return $this;
}
public function getItemNumber(): ?string
{
return $this->itemNumber;
}
public function setItemNumber(string $itemNumber): static
{
$this->itemNumber = $itemNumber;
return $this;
}
public function getMaterialNumber(): ?string
{
return $this->materialNumber;
}
public function setMaterialNumber(string $materialNumber): static
{
$this->materialNumber = $materialNumber;
return $this;
}
public function getSupplierPartNumber(): ?string
{
return $this->supplierPartNumber;
}
public function setSupplierPartNumber(?string $supplierPartNumber): static
{
$this->supplierPartNumber = $supplierPartNumber;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): static
{
$this->description = $description;
return $this;
}
public function getSupplier(): ?string
{
return $this->supplier;
}
public function setSupplier(string $supplier): static
{
$this->supplier = $supplier;
return $this;
}
public function getOwner(): ?string
{
return $this->owner;
}
public function setOwner(?string $owner): static
{
$this->owner = $owner;
return $this;
}
public function getPreservation(): ?string
{
return $this->preservation;
}
public function setPreservation(?string $preservation): static
{
$this->preservation = $preservation;
return $this;
}
public function getSearchable(): ?string
{
return $this->searchable;
}
public function setSearchable(?string $searchable): static
{
$this->searchable = $searchable;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity;
}
public function setQuantity(int $quantity): static
{
$this->quantity = $quantity;
return $this;
}
public function getUnitPrice(): ?float
{
return $this->unitPrice;
}
public function setUnitPrice(?float $unitPrice): static
{
$this->unitPrice = $unitPrice;
return $this;
}
public function getValue(): ?float
{
return $this->value;
}
public function setValue(?float $value): static
{
$this->value = $value;
return $this;
}
public function getCurrency(): ?string
{
return $this->currency;
}
public function setCurrency(?string $currency): static
{
$this->currency = $currency;
return $this;
}
public function getSpfr(): ?string
{
return $this->spfr;
}
public function setSpfr(?string $spfr): static
{
$this->spfr = $spfr;
return $this;
}
public function isDegrouped(): ?bool
{
return $this->degrouped;
}
public function setDegrouped(?bool $degrouped): static
{
$this->degrouped = $degrouped;
return $this;
}
public function isCertified(): ?bool
{
return $this->certified;
}
public function setCertified(?bool $certified): static
{
$this->certified = $certified;
return $this;
}
public function isFatRequired(): ?bool
{
return $this->fatRequired;
}
public function setFatRequired(bool $fatRequired): static
{
$this->fatRequired = $fatRequired;
return $this;
}
public function isRetired(): ?bool
{
return $this->retired;
}
public function setRetired(bool $retired): static
{
$this->retired = $retired;
return $this;
}
public function isExpeditable(): ?bool
{
return $this->expeditable;
}
public function setExpeditable(?bool $expeditable): static
{
$this->expeditable = $expeditable;
return $this;
}
public function isDangerous(): ?bool
{
return $this->dangerous;
}
public function setDangerous(?bool $dangerous): static
{
$this->dangerous = $dangerous;
return $this;
}
public function isProhibited(): ?bool
{
return $this->prohibited;
}
public function setProhibited(?bool $prohibited): static
{
$this->prohibited = $prohibited;
return $this;
}
/** @return Collection<int, Movement> */
public function getMovements(): Collection
{
return $this->movements;
}
public function addMovement(Movement $movement): static
{
if (!$this->movements->contains($movement)) {
$this->movements->add($movement);
$movement->setMaterial($this);
}
return $this;
}
public function removeMovement(Movement $movement): static
{
if ($this->movements->removeElement($movement)) {
// set the owning side to null (unless already changed)
if ($movement->getMaterial() === $this) {
$movement->setMaterial(null);
}
}
return $this;
}
}