<?php
namespace App\Entity;
use App\Repository\TopicRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: TopicRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Topic
{
use \App\Traits\EntityDateTimeAbleTrait;
const STATUS_ACTIVE = 1;
const STATUS_INACTIVE = 0;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
/**
* @Gedmo\Translatable
*/
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $title = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $ordering = null;
#[ORM\OneToMany(targetEntity: Faq::class, mappedBy: 'topic', orphanRemoval: true, cascade: ['persist'])]
private Collection $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;
}
public function getOrdering(): ?int
{
return $this->ordering;
}
public function setOrdering(?int $ordering): self
{
$this->ordering = $ordering;
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[] = $faq;
$faq->setTopic($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->getTopic() === $this) {
$faq->setTopic(null);
}
}
return $this;
}
}