src/Entity/Category.php line 12
<?phpnamespace App\Entity;use App\Repository\CategoryRepository;use Doctrine\Common\Collections\Collection;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CategoryRepository::class)]class Category{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 255)]private ?string $name = null;#[ORM\ManyToMany(targetEntity: BlogPost::class, mappedBy: 'categories')]private Collection $blogPosts;public function __construct(){$this->blogPosts = new ArrayCollection();}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): static{$this->name = $name;return $this;}/*** @return Collection<int, BlogPost>*/public function getBlogPosts(): Collection{return $this->blogPosts;}public function addBlogPost(BlogPost $blogPost): self{if (!$this->blogPosts->contains($blogPost)) {$this->blogPosts->add($blogPost);$blogPost->addCategory($this);}return $this;}public function removeBlogPost(BlogPost $blogPost): self{if ($this->blogPosts->removeElement($blogPost)) {$blogPost->removeCategory($this);}return $this;}}