*/ #[ORM\ManyToMany(targetEntity: Post::class, mappedBy: 'tree')] private Collection $posts; public function __construct() { $this->posts = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getCat(): ?Cat { return $this->cat; } public function setCat(?Cat $cat): static { $this->cat = $cat; return $this; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): static { $this->label = $label; return $this; } public function getCode(): ?string { return $this->code; } public function setCode(string $code): static { $this->code = $code; return $this; } public function getSort(): ?string { return $this->sort; } public function setSort(?string $sort): static { $this->sort = $sort; 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->addTree($this); } return $this; } public function removePost(Post $post): static { if ($this->posts->removeElement($post)) { $post->removeTree($this); } return $this; } public function __toString(): string { return $this->getLabel(); } }