src/Entity/Product.php line 21
<?phpnamespace App\Entity;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Metadata\ApiResource;use App\Repository\ProductRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;#[ApiResource(normalizationContext: ['groups' => ['read_prod']])]#[ApiFilter(SearchFilter::class, properties: ['name' => 'exact', 'qrCode' => 'exact'])]#[ORM\Entity(repositoryClass: ProductRepository::class)]#[UniqueEntity("qrCode")]class Product{#[Groups('read_prod')]#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[Groups('read_prod')]#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\Column(length: 255, nullable: true)]private ?string $description = null;#[Groups('read_prod')]#[ORM\Column]private ?float $qty = null;#[ORM\Column(nullable: true)]private ?float $prixRevient = null;#[Groups('read_prod')]#[ORM\Column(nullable: true)]private ?float $prixVente = null;#[Groups('read_prod')]#[ORM\Column(length: 255,unique: true,nullable: true)]private ?string $qrCode = null;#[ORM\OneToMany(mappedBy: 'product', targetEntity: OrderLine::class)]private Collection $orderLines;#[ORM\OneToMany(mappedBy: 'product', targetEntity: Stock::class)]private Collection $stocks;public function __construct(){$this->orderLines = new ArrayCollection();$this->stocks = new ArrayCollection();$this->qty = 0;$this->prixRevient = 0;}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(?string $description): self{$this->description = $description;return $this;}public function getQty(): ?float{return $this->qty;}public function setQty(float $qty): self{$this->qty = $qty;return $this;}public function getPrixRevient(): ?float{return $this->prixRevient;}public function setPrixRevient(?float $prixRevient): self{$this->prixRevient = $prixRevient;return $this;}public function getPrixVente(): ?float{return $this->prixVente;}public function setPrixVente(?float $prixVente): self{$this->prixVente = $prixVente;return $this;}public function getQrCode(): ?string{return $this->qrCode;}public function setQrCode(?string $qrCode): self{$this->qrCode = $qrCode;return $this;}/*** @return Collection<int, OrderLine>*/public function getOrderLines(): Collection{return $this->orderLines;}public function addOrderLine(OrderLine $orderLine): self{if (!$this->orderLines->contains($orderLine)) {$this->orderLines->add($orderLine);$orderLine->setProduct($this);}return $this;}public function removeOrderLine(OrderLine $orderLine): self{if ($this->orderLines->removeElement($orderLine)) {// set the owning side to null (unless already changed)if ($orderLine->getProduct() === $this) {$orderLine->setProduct(null);}}return $this;}/*** @return Collection<int, Stock>*/public function getStocks(): Collection{return $this->stocks;}public function addStock(Stock $stock): self{if (!$this->stocks->contains($stock)) {$this->stocks->add($stock);$stock->setProduct($this);}return $this;}public function removeStock(Stock $stock): self{if ($this->stocks->removeElement($stock)) {// set the owning side to null (unless already changed)if ($stock->getProduct() === $this) {$stock->setProduct(null);}}return $this;}public function __toString(): string{return $this->name;}}