<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: \App\Repository\TargetPublicRepository::class)]class TargetPublic implements \Stringable{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private ?int $id = null; #[ORM\Column(type: 'string', length: 255, nullable: true)] private ?string $name= null; #[ORM\ManyToMany(targetEntity: \App\Entity\Post::class, mappedBy: 'targetpublics')] private mixed $posts; #[ORM\OneToMany(targetEntity: \App\Entity\User::class, mappedBy: 'public')] private mixed $users; public function __construct() { $this->posts = new ArrayCollection(); $this->users = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(?string $name): self { $this->name = $name; return $this; } /** * @return Collection|Post[] */ public function getPosts(): Collection { return $this->posts; } public function addPost(Post $post): self { if (!$this->posts->contains($post)) { $this->posts[] = $post; $post->addTargetpublic($this); } return $this; } public function removePost(Post $post): self { if ($this->posts->contains($post)) { $this->posts->removeElement($post); $post->removeTargetpublic($this); } return $this; } public function __toString(): string { return (string) $this->getName(); } /** * @return Collection|User[] */ public function getUsers(): Collection { return $this->users; } public function addUser(User $user): self { if (!$this->users->contains($user)) { $this->users[] = $user; $user->setPublic($this); } return $this; } public function removeUser(User $user): self { if ($this->users->contains($user)) { $this->users->removeElement($user); // set the owning side to null (unless already changed) if ($user->getPublic() === $this) { $user->setPublic(null); } } return $this; }}