<?phpnamespace App\Entity;use App\Repository\UnitMeasurementRepository;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\Component\Serializer\Annotation\Groups;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: UnitMeasurementRepository::class)]class UnitMeasurement{ 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(length: 255)] #[Assert\NotNull()] #[Assert\Length(max: 255)] #[Groups("serial")] private ?string $name = null; #[ORM\OneToMany(mappedBy: 'unitMeasurement', targetEntity: Product::class)] private Collection $products; #[ORM\OneToMany(mappedBy: 'unitMeasurement', targetEntity: ProductUnique::class)] private Collection $productUniques; public function __construct() { $this->products = new ArrayCollection(); } 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; } /** * @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->setUnitMeasurement($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->getUnitMeasurement() === $this) { $product->setUnitMeasurement(null); } } return $this; } /** * @return Collection<int, Product> */ public function getProductUniques(): Collection { return $this->products; } public function addProductUnique(ProductUnique $productUnique): self { if (!$this->productUniques->contains($productUnique)) { $this->productUniques->add($productUnique); $productUnique->setUnitMeasurement($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->getUnitMeasurement() === $this) { $productUnique->setUnitMeasurement(null); } } return $this; }}