src/Entity/Allergen.php line 16
<?phpnamespace App\Entity;use App\Repository\AllergenRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use Symfony\Component\Serializer\Annotation\Groups;use Symfony\Component\Uid\Uuid;#[ORM\Entity(repositoryClass: AllergenRepository::class)]#[UniqueEntity(['whitelabel', 'name'], message: 'Record with this name already exists.')]class Allergen{#[ORM\Id]#[ORM\Column(type: 'uuid', unique: true)]#[Groups(['BASE'])]private ?string $id = null;#[ORM\ManyToOne(inversedBy: 'allergens')]#[ORM\JoinColumn(nullable: false)]private ?Whitelabel $whitelabel = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $createDate = null;#[ORM\ManyToOne(inversedBy: 'allergens')]#[ORM\JoinColumn(nullable: false)]private ?User $creatorUser = null;#[ORM\ManyToMany(targetEntity: Product::class, mappedBy: 'allergens')]private Collection $products;#[ORM\Column(length: 255)]private ?string $name = null;public function __construct(){$this->id = Uuid::v4();$this->products = new ArrayCollection();}public function getId(): ?string{return $this->id;}public function __toString(){return $this->getName();}public function getWhitelabel(): ?Whitelabel{return $this->whitelabel;}public function setWhitelabel(?Whitelabel $whitelabel): self{$this->whitelabel = $whitelabel;return $this;}public function getCreateDate(): ?\DateTimeInterface{return $this->createDate;}public function setCreateDate(\DateTimeInterface $createDate): self{$this->createDate = $createDate;return $this;}public function getCreatorUser(): ?User{return $this->creatorUser;}public function setCreatorUser(?User $creatorUser): self{$this->creatorUser = $creatorUser;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->addAllergen($this);}return $this;}public function removeProduct(Product $product): self{if ($this->products->removeElement($product)) {$product->removeAllergen($this);}return $this;}public function getName(): ?string{return $this->name;}public function setName(string $name): self{$this->name = $name;return $this;}}