*/ #[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'speaker')] private Collection $notes; public function __construct() { $this->notes = new ArrayCollection(); } public function setId(?Uuid $id): static { $this->id = $id; return $this; } public static function idFromString(string $id): Uuid { return Uuid::fromString($id); } public function getId(): ?Uuid { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getUser(): ?User { return $this->user; } public function setUser(?User $user): static { $this->user = $user; return $this; } /** * @return Collection */ public function getNotes(): Collection { return $this->notes; } public function addNote(Note $note): static { if (!$this->notes->contains($note)) { $this->notes->add($note); $note->setSpeaker($this); } return $this; } public function removeNote(Note $note): static { if ($this->notes->removeElement($note)) { // set the owning side to null (unless already changed) if ($note->getSpeaker() === $this) { $note->setSpeaker(null); } } return $this; } public function jsonSerialize(): array { return [ 'id' => $this->getId(), 'name' => $this->getName(), 'note_count' => count($this->notes), ]; } }