<?phpnamespace App\Entity;use App\Repository\IvaRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Blameable\Traits\BlameableEntity;use Gedmo\Timestampable\Traits\TimestampableEntity;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: IvaRepository::class)]#[UniqueEntity('percentage')]class Iva{ use BlameableEntity; //Hook blameable behaviour. Updates createdBy, updatedBy fields use TimestampableEntity; //Hook timestampable behaviour. Updates createdAt, updatedAt fields #[ORM\Id] #[ORM\GeneratedValue(strategy: "IDENTITY")] #[ORM\Column] #[Groups("serial")] private ?int $id = null; #[ORM\Column] #[Assert\NotNull()] #[Groups("serial")] private ?float $percentage = null; #[ORM\Column(length: 255, nullable: true)] #[Assert\Length(max: 255)] private ?string $description = null; #[ORM\OneToMany(mappedBy: 'iva', targetEntity: Product::class)] private Collection $products; #[ORM\OneToMany(mappedBy: 'iva', targetEntity: Product::class)] private Collection $productUniques; public function __toString() { return $this->percentage; } public function __construct() { $this->products = new ArrayCollection(); $this->productUniques = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getPercentage(): ?float { return $this->percentage; } public function setPercentage(float $percentage): self { $this->percentage = $percentage; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): self { $this->description = $description; return $this; } /** * @return Collection<int, Product> */ public function getProducts(): Collection { return $this->products; } public function addProduct(Product $product): self { if (!$this->products->contains($product)) { $this->products->add($product); $product->setIva($this); } return $this; } public function removeProduct(Product $product): self { if ($this->products->removeElement($product)) { // set the owning side to null (unless already changed) if ($product->getIva() === $this) { $product->setIva(null); } } return $this; } /** * @return Collection<int, Product> */ public function getProductUniques(): Collection { return $this->productUniques; } public function addProductUnique(ProductUnique $productUnique): self { if (!$this->productUniques->contains($productUnique)) { $this->productUniques->add($productUnique); $productUnique->setIva($this); } return $this; } public function removeProductUnique(ProductUnique $productUnique): self { if ($this->productUniques->removeElement($productUnique)) { // set the owning side to null (unless already changed) if ($productUnique->getIva() === $this) { $productUnique->setIva(null); } } return $this; }}