<?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 $title;
/**
* @ORM\OneToMany(targetEntity=BlogArticle::class, mappedBy="category", orphanRemoval=true)
*/
private $blogArticles;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
public function __construct()
{
$this->blogArticles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection<int, BlogArticle>
*/
public function getBlogArticles(): Collection
{
return $this->blogArticles;
}
public function addBlogArticle(BlogArticle $blogArticle): self
{
if (!$this->blogArticles->contains($blogArticle)) {
$this->blogArticles[] = $blogArticle;
$blogArticle->setCategory($this);
}
return $this;
}
public function removeBlogArticle(BlogArticle $blogArticle): self
{
if ($this->blogArticles->removeElement($blogArticle)) {
// set the owning side to null (unless already changed)
if ($blogArticle->getCategory() === $this) {
$blogArticle->setCategory(null);
}
}
return $this;
}
public function __toString()
{
return $this->getTitle();
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
}