'ipartial', 'reference' => 'ipartial', 'typeProduct' => 'exact', 'typeProduct.name' => 'ipartial'])] #[ApiFilter(OrderFilter::class, properties: ['name', 'createdAt', 'supplierPrice'])] #[ApiResource( description: 'Produits du catalogue fournisseur. Un produit possède une référence, un prix indicatif, un type, des fournisseurs et des documents. Il peut être lié à des machines.', operations: [ new Get(security: "is_granted('ROLE_VIEWER')"), new GetCollection(security: "is_granted('ROLE_VIEWER')"), new Post(security: "is_granted('ROLE_GESTIONNAIRE')"), new Put(security: "is_granted('ROLE_GESTIONNAIRE')"), new Patch(security: "is_granted('ROLE_GESTIONNAIRE')"), new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"), ], normalizationContext: ['groups' => ['product:read']], paginationClientItemsPerPage: true, paginationMaximumItemsPerPage: 200 )] class Product { use CuidEntityTrait; #[ORM\Id] #[ORM\Column(type: Types::STRING, length: 36)] #[Groups(['product:read', 'document:list'])] private ?string $id = null; #[ORM\Column(type: Types::STRING, length: 255, unique: true)] #[Groups(['product:read', 'document:list'])] private string $name; #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] #[Groups(['product:read'])] private ?string $reference = null; #[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true, name: 'supplierPrice')] #[Groups(['product:read'])] private ?string $supplierPrice = null; #[ORM\ManyToOne(targetEntity: ModelType::class, inversedBy: 'products')] #[ORM\JoinColumn(name: 'typeProductId', referencedColumnName: 'id', nullable: true)] #[Groups(['product:read'])] private ?ModelType $typeProduct = null; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Constructeur::class, inversedBy: 'products')] #[ORM\JoinTable( name: '_ProductConstructeurs', joinColumns: [new ORM\JoinColumn(name: 'A', referencedColumnName: 'id', onDelete: 'CASCADE')], inverseJoinColumns: [new ORM\InverseJoinColumn(name: 'B', referencedColumnName: 'id', onDelete: 'CASCADE')] )] #[Groups(['product:read'])] private Collection $constructeurs; /** * @var Collection */ #[ORM\OneToMany(mappedBy: 'product', targetEntity: Document::class)] #[Groups(['product:read'])] private Collection $documents; /** * @var Collection */ #[ORM\OneToMany(mappedBy: 'product', targetEntity: CustomFieldValue::class)] #[Groups(['product:read'])] private Collection $customFieldValues; /** * @var Collection */ #[ORM\OneToMany(mappedBy: 'product', targetEntity: Piece::class)] private Collection $pieces; /** * @var Collection */ #[ORM\OneToMany(mappedBy: 'product', targetEntity: Composant::class)] private Collection $composants; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: Piece::class, mappedBy: 'products')] private Collection $linkedPieces; /** * @var Collection */ #[ORM\OneToMany(mappedBy: 'product', targetEntity: MachineProductLink::class)] private Collection $machineLinks; #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] #[Groups(['product:read'])] private DateTimeImmutable $createdAt; #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'updatedAt')] #[Groups(['product:read'])] private DateTimeImmutable $updatedAt; public function __construct() { $this->createdAt = new DateTimeImmutable(); $this->updatedAt = new DateTimeImmutable(); $this->constructeurs = new ArrayCollection(); $this->documents = new ArrayCollection(); $this->customFieldValues = new ArrayCollection(); $this->pieces = new ArrayCollection(); $this->composants = new ArrayCollection(); $this->linkedPieces = new ArrayCollection(); $this->machineLinks = new ArrayCollection(); } public function getName(): string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getReference(): ?string { return $this->reference; } public function setReference(?string $reference): static { $this->reference = $reference; return $this; } public function getSupplierPrice(): ?string { return $this->supplierPrice; } public function setSupplierPrice(?string $supplierPrice): static { $this->supplierPrice = $supplierPrice; return $this; } public function getTypeProduct(): ?ModelType { return $this->typeProduct; } public function setTypeProduct(?ModelType $typeProduct): static { $this->typeProduct = $typeProduct; return $this; } /** * @return Collection */ public function getConstructeurs(): Collection { return $this->constructeurs; } public function addConstructeur(Constructeur $constructeur): static { if (!$this->constructeurs->contains($constructeur)) { $this->constructeurs->add($constructeur); } return $this; } public function removeConstructeur(Constructeur $constructeur): static { $this->constructeurs->removeElement($constructeur); return $this; } /** * @return Collection */ public function getDocuments(): Collection { return $this->documents; } /** * @return Collection */ public function getCustomFieldValues(): Collection { return $this->customFieldValues; } /** * @return Collection */ public function getLinkedPieces(): Collection { return $this->linkedPieces; } }