<?php
namespace App\Entity;
use App\Repository\BlogCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=BlogCategoryRepository::class)
*/
class BlogCategory
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Article::class, mappedBy="blogCategory")
*/
private $articles;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $categorySlug;
public function __construct()
{
$this->articles = 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|Article[]
*/
public function getArticles(): Collection
{
return $this->articles;
}
public function addArticle(Article $article): self
{
if (!$this->articles->contains($article)) {
$this->articles[] = $article;
$article->setBlogCategory($this);
}
return $this;
}
public function removeArticle(Article $article): self
{
if ($this->articles->contains($article)) {
$this->articles->removeElement($article);
// set the owning side to null (unless already changed)
if ($article->getBlogCategory() === $this) {
$article->setBlogCategory(null);
}
}
return $this;
}
public function getCategorySlug(): ?string
{
return $this->categorySlug;
}
public function setCategorySlug(?string $categorySlug): self
{
$this->categorySlug = $categorySlug;
return $this;
}
}