*/ #[ORM\OneToMany(targetEntity: Post::class, mappedBy: 'species')] private Collection $posts; public function __construct() { $this->posts = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getScientificName(): ?string { return $this->scientific_name; } public function setScientificName(string $scientific_name): static { $this->scientific_name = $scientific_name; return $this; } public function getVernacularName(): ?string { return $this->vernacular_name; } public function setVernacularName(string $vernacular_name): static { $this->vernacular_name = $vernacular_name; return $this; } public function getRegion(): ?string { return $this->region; } public function setRegion(string $region): static { $this->region = $region; return $this; } /** * @return Collection */ public function getPosts(): Collection { return $this->posts; } public function addPost(Post $post): static { if (!$this->posts->contains($post)) { $this->posts->add($post); $post->setSpecies($this); } return $this; } public function removePost(Post $post): static { if ($this->posts->removeElement($post)) { // set the owning side to null (unless already changed) if ($post->getSpecies() === $this) { $post->setSpecies(null); } } return $this; } }