src/Entity/FaqQuestion.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Constants\ActiveConstants;
  4. use App\Repository\FaqQuestionRepository;
  5. use App\Traits\ActivityTrait;
  6. use App\Traits\TimeTrackTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[ORM\Entity(repositoryClassFaqQuestionRepository::class)]
  14. #[ORM\HasLifecycleCallbacks]
  15. class FaqQuestion
  16. {
  17.     use TimeTrackTrait;
  18.     use ActivityTrait;
  19.     #[ORM\Id]
  20.     #[ORM\GeneratedValue]
  21.     #[ORM\Column]
  22.     private ?int $id null;
  23.     #[ORM\Column(typeTypes::TEXT)]
  24.     private ?string $title null;
  25.     #[ORM\ManyToMany(targetEntity"App\Entity\Company"inversedBy'faqQuestions'cascade: ['persist'], orphanRemovalfalse)]
  26.     #[ORM\JoinTable(name'faq_questions_companies')]
  27.     #[ORM\JoinColumn(name'question_id'referencedColumnName'id'onDelete'CASCADE')]
  28.     #[ORM\InverseJoinColumn(name'company_id'referencedColumnName'id'onDelete'CASCADE')]
  29.     private $companies;
  30.     #[Assert\NotNull]
  31.     #[ORM\Column(typeTypes::JSONnullablefalse)]
  32.     private $page null;
  33.     #[ORM\Column(name'position'type'integer'nullabletrueoptions: ['unsigned' => true])]
  34.     #[Gedmo\SortablePosition]
  35.     private ?int $position 1;
  36.     #[ORM\OneToMany(mappedBy'faqQuestion'targetEntityFaqAnswer::class, orphanRemovaltrue)]
  37.     private Collection $faqAnswers;
  38.     #[ORM\ManyToOne(targetEntityOperator::class, inversedBy'faqQuestions')]
  39.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  40.     private ?Operator $operator null;
  41.     public function __construct()
  42.     {
  43.         $this->faqAnswers = new ArrayCollection();
  44.         $this->companies = new ArrayCollection();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getTitle(): ?string
  51.     {
  52.         return $this->title;
  53.     }
  54.     public function setTitle(string $title): static
  55.     {
  56.         $this->title $title;
  57.         return $this;
  58.     }
  59.     /**
  60.      * Set createdAt.
  61.      *
  62.      * @param \DateTime|null $createdAt
  63.      *
  64.      * @return FaqQuestion
  65.      */
  66.     public function setCreatedAt($createdAt null)
  67.     {
  68.         $this->createdAt $createdAt;
  69.         return $this;
  70.     }
  71.     /**
  72.      * Get createdAt.
  73.      *
  74.      * @return \DateTime|null
  75.      */
  76.     public function getCreatedAt()
  77.     {
  78.         return $this->createdAt;
  79.     }
  80.     /**
  81.      * Set updatedAt.
  82.      *
  83.      * @param \DateTime|null $updatedAt
  84.      *
  85.      * @return FaqQuestion
  86.      */
  87.     public function setUpdatedAt($updatedAt null)
  88.     {
  89.         $this->updatedAt $updatedAt;
  90.         return $this;
  91.     }
  92.     /**
  93.      * Get updatedAt.
  94.      *
  95.      * @return \DateTime|null
  96.      */
  97.     public function getUpdatedAt()
  98.     {
  99.         return $this->updatedAt;
  100.     }
  101.     /**
  102.      * Set active.
  103.      *
  104.      * @param int $active
  105.      *
  106.      * @return FaqQuestion
  107.      */
  108.     public function setActive($active)
  109.     {
  110.         $this->active $active;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get active.
  115.      *
  116.      * @return int
  117.      */
  118.     public function getActive()
  119.     {
  120.         return $this->active;
  121.     }
  122.     public function getActiveLabel(): string
  123.     {
  124.         return $this->active ActiveConstants::LABEL_YES ActiveConstants::LABEL_NO;
  125.     }
  126.     /**
  127.      * @return Collection<int, FaqAnswer>
  128.      */
  129.     public function getFaqAnswers(): Collection
  130.     {
  131.         return $this->faqAnswers;
  132.     }
  133.     public function addFaqAnswer(FaqAnswer $faqAnswer): static
  134.     {
  135.         if (!$this->faqAnswers->contains($faqAnswer)) {
  136.             $this->faqAnswers->add($faqAnswer);
  137.             $faqAnswer->setFaqQuestion($this);
  138.         }
  139.         return $this;
  140.     }
  141.     public function removeFaqAnswer(FaqAnswer $faqAnswer): static
  142.     {
  143.         if ($this->faqAnswers->removeElement($faqAnswer)) {
  144.             // set the owning side to null (unless already changed)
  145.             if ($faqAnswer->getFaqQuestion() === $this) {
  146.                 $faqAnswer->setFaqQuestion(null);
  147.             }
  148.         }
  149.         return $this;
  150.     }
  151.     public function __toString()
  152.     {
  153.         return $this->getTitle();
  154.     }
  155.     public function getPage(): array
  156.     {
  157.         return $this->page;
  158.     }
  159.     public function setPage(array $page): static
  160.     {
  161.         foreach ($page as &$value) {
  162.             $value "{$value}";
  163.         }
  164.         $this->page $page;
  165.         return $this;
  166.     }
  167.     public function getPosition(): ?int
  168.     {
  169.         return $this->position;
  170.     }
  171.     public function setPosition(?int $position): self
  172.     {
  173.         $this->position $position;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @return Collection<int, Company>
  178.      */
  179.     public function getCompanies(): Collection
  180.     {
  181.         return $this->companies;
  182.     }
  183.     public function addCompany(Company $company): static
  184.     {
  185.         if (!$this->companies->contains($company)) {
  186.             $this->companies->add($company);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeCompany(Company $company): static
  191.     {
  192.         $this->companies->removeElement($company);
  193.         return $this;
  194.     }
  195.     public function getOperator(): ?Operator
  196.     {
  197.         return $this->operator;
  198.     }
  199.     public function setOperator(?Operator $operator): static
  200.     {
  201.         $this->operator $operator;
  202.         return $this;
  203.     }
  204. }