<?php
namespace App\Entity;
use App\Repository\FaqCategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=FaqCategoryRepository::class)
*/
class FaqCategory
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=Faq::class, mappedBy="category", orphanRemoval=true)
*/
private $questions;
public function __construct()
{
$this->questions = 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<int, Faq>
*/
public function getQuestions(): Collection
{
return $this->questions;
}
public function addQuestion(Faq $question): self
{
if (!$this->questions->contains($question)) {
$this->questions[] = $question;
$question->setCategory($this);
}
return $this;
}
public function removeQuestion(Faq $question): self
{
if ($this->questions->removeElement($question)) {
// set the owning side to null (unless already changed)
if ($question->getCategory() === $this) {
$question->setCategory(null);
}
}
return $this;
}
}