<?php
namespace App\Entity;
use App\Repository\FaqThemeRepository;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: FaqThemeRepository::class)]
class FaqTheme
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\OneToMany(mappedBy: 'faqTheme', targetEntity: Faq::class, cascade: ['persist', 'remove']),
Assert\NotBlank(),
Assert\Valid()
]
private $faqs ;
public function __construct()
{
$this->faqs = 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, Faq>
*/
public function getFaqs(): Collection
{
return $this->faqs;
}
public function addFaq(Faq $faq): self
{
if (!$this->faqs->contains($faq)) {
$this->faqs->add($faq);
$faq->setFaqTheme($this);
}
return $this;
}
public function removeFaq(Faq $faq): self
{
if ($this->faqs->removeElement($faq)) {
// set the owning side to null (unless already changed)
if ($faq->getFaqTheme() === $this) {
$faq->setFaqTheme(null);
}
}
return $this;
}
}