*/ #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'aliasOf')] private Collection $aliases; public function __construct( #[ORM\Id] #[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\Column(type: UlidType::NAME, unique: true)] #[ORM\CustomIdGenerator(class: UlidGenerator::class)] private Ulid|null $id = new Ulid ) { $this->aliases = new ArrayCollection; } public function getId(): Ulid|null { return $this->id; } public function getName(): string|null { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getFoodVendor(): FoodVendor|null { return $this->foodVendor; } public function setFoodVendor(FoodVendor|null $foodVendor): static { $this->foodVendor = $foodVendor; return $this; } public function isDeleted(): bool { return $this->getDeletedAt() instanceof DateTimeImmutable; } public function delete(): static { $this->setDeletedAt(new DateTimeImmutable); return $this; } public function getDeletedAt(): DateTimeImmutable|null { return $this->deletedAt; } public function setDeletedAt(DateTimeImmutable|null $deletedAt = new DateTimeImmutable): static { $this->deletedAt = $deletedAt; return $this; } public function getAliasOf(): self|null { return $this->aliasOf; } public function setAliasOf(self|null $aliasOf): static { $this->aliasOf = $aliasOf; return $this; } /** * @return Collection */ public function getAliases(): Collection { return $this->aliases; } public function addAlias(self $alias): static { if (! $this->aliases->contains($alias)) { $this->aliases->add($alias); $alias->setAliasOf($this); } return $this; } public function removeAlias(self $alias): static { // set the owning side to null (unless already changed) if ($this->aliases->removeElement($alias) && $alias->getAliasOf() === $this) { $alias->setAliasOf(null); } return $this; } }