src/Entity/Faq.php line 36

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\FaqRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use ApiPlatform\Metadata\Get;
  10. use ApiPlatform\Metadata\Post;
  11. use ApiPlatform\Metadata\Put;
  12. use ApiPlatform\Metadata\Delete;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use ApiPlatform\Metadata\ApiFilter;
  15. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  16. #[ORM\Entity(repositoryClassFaqRepository::class)]
  17. // #[Get]
  18. // #[Put(security: "is_granted('ROLE_ADMIN')")]
  19. // #[Post(security: "is_granted('ROLE_ADMIN')")]
  20. // #[Delete(security: "is_granted('ROLE_ADMIN')")]
  21. #[ApiResource(
  22.     normalizationContext: ['groups' => ['faq:read']],
  23.     denormalizationContext: ['groups' => ['faq:write']],
  24.     order: ['id' => 'DESC'],
  25.     // paginationPartial: true
  26. )]
  27. #[ApiFilter(SearchFilter::class, properties: [
  28.     'name' => 'ipartial',
  29.     'category.id' => 'exact',
  30. ])]
  31. class Faq
  32. {
  33.     #[Groups(['faq:read''faq:write'])]
  34.     #[ORM\Id]
  35.     #[ORM\GeneratedValue]
  36.     #[ORM\Column]
  37.     private ?int $id null;
  38.     #[Groups(['faq:read''faq:write'])]
  39.     #[ORM\Column(length255)]
  40.     private ?string $name null;
  41.     #[Groups(['faq:read''faq:write'])]
  42.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  43.     private ?\DateTimeInterface $date null;
  44.     #[Groups(['faq:read''faq:write'])]
  45.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  46.     private ?string $contentShort null;
  47.     #[Groups(['faq:read''faq:write'])]
  48.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  49.     private ?string $contentFull null;
  50.     #[Groups(['faq:read''faq:write'])]
  51.     #[ORM\Column(length2)]
  52.     private ?string $active null;
  53.     #[Groups(['faq:read''faq:write'])]
  54.     #[ORM\Column(length2nullabletrue)]
  55.     private ?string $top null;
  56.     #[Groups(['faq:read''faq:write'])]
  57.     #[ORM\ManyToMany(targetEntityCategory::class, inversedBy'faqs')]
  58.     private Collection $category;
  59.     #[ORM\ManyToOne(inversedBy'faqs')]
  60.     private ?User $createdUser null;
  61.     #[Groups(['faq:read''faq:write'])]
  62.     #[ORM\ManyToOne(inversedBy'modifiedFaq')]
  63.     private ?User $modifiedUser null;
  64.     #[Groups(['faq:read''faq:write'])]
  65.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  66.     private ?\DateTimeInterface $dateEntered null;
  67.     #[Groups(['faq:read''faq:write'])]
  68.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  69.     private ?\DateTimeInterface $dateModified null;
  70.     #[Groups(['faq:read''faq:write'])]
  71.     #[ORM\ManyToOne(inversedBy'faqs')]
  72.     private ?Languages $language null;
  73.     #[Groups(['faq:read''faq:write'])]
  74.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'translations')]
  75.     private ?self $translation null;
  76.     /**
  77.      * @var Collection<int, self>
  78.      */
  79.     #[Groups(['faq:read''faq:write'])]
  80.     #[ORM\OneToMany(mappedBy'translation'targetEntityself::class)]
  81.     private Collection $translations;
  82.     
  83.     public function __construct()
  84.     {
  85.         $this->category = new ArrayCollection();
  86.         $this->translations = new ArrayCollection();
  87.     }
  88.     public function getId(): ?int
  89.     {
  90.         return $this->id;
  91.     }
  92.     public function getName(): ?string
  93.     {
  94.         return $this->name;
  95.     }
  96.     public function setName(string $name): self
  97.     {
  98.         $this->name $name;
  99.         return $this;
  100.     }
  101.     public function getDate(): ?\DateTimeInterface
  102.     {
  103.         return $this->date;
  104.     }
  105.     public function setDate(\DateTimeInterface $date): self
  106.     {
  107.         $this->date $date;
  108.         return $this;
  109.     }
  110.     public function getContentShort(): ?string
  111.     {
  112.         return $this->contentShort;
  113.     }
  114.     public function setContentShort(?string $contentShort): self
  115.     {
  116.         $this->contentShort $contentShort;
  117.         return $this;
  118.     }
  119.     public function getContentFull(): ?string
  120.     {
  121.         return $this->contentFull;
  122.     }
  123.     public function setContentFull(?string $contentFull): self
  124.     {
  125.         $this->contentFull $contentFull;
  126.         return $this;
  127.     }
  128.     public function getActive(): ?string
  129.     {
  130.         return $this->active;
  131.     }
  132.     public function setActive(string $active): self
  133.     {
  134.         $this->active $active;
  135.         return $this;
  136.     }
  137.     public function getTop(): ?string
  138.     {
  139.         return $this->top;
  140.     }
  141.     public function setTop(?string $top): self
  142.     {
  143.         $this->top $top;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection<int, Category>
  148.      */
  149.     public function getCategory(): Collection
  150.     {
  151.         return $this->category;
  152.     }
  153.     public function addCategory(Category $category): static
  154.     {
  155.         if (!$this->category->contains($category)) {
  156.             $this->category->add($category);
  157.         }
  158.         return $this;
  159.     }
  160.     public function getCreatedUser(): ?User
  161.     {
  162.         return $this->createdUser;
  163.     }
  164.     public function setCreatedUser(?User $createdUser): static
  165.     {
  166.         $this->createdUser $createdUser;
  167.         return $this;
  168.     }
  169.     public function removeCategory(Category $category): static
  170.     {
  171.         $this->category->removeElement($category);
  172.         return $this;
  173.     }
  174.     
  175.     public function getModifiedUser(): ?User
  176.     {
  177.         return $this->modifiedUser;
  178.     }
  179.     public function setModifiedUser(?User $modifiedUser): static
  180.     {
  181.         $this->modifiedUser $modifiedUser;
  182.         return $this;
  183.     }
  184.     public function getDateEntered(): ?\DateTimeInterface
  185.     {
  186.         return $this->dateEntered;
  187.     }
  188.     public function setDateEntered(?\DateTimeInterface $dateEntered): static
  189.     {
  190.         $this->dateEntered $dateEntered;
  191.         return $this;
  192.     }
  193.     public function getDateModified(): ?\DateTimeInterface
  194.     {
  195.         return $this->dateModified;
  196.     }
  197.     public function setDateModified(?\DateTimeInterface $dateModified): static
  198.     {
  199.         $this->dateModified $dateModified;
  200.         return $this;
  201.     }
  202.     public function getLanguage(): ?Languages
  203.     {
  204.         return $this->language;
  205.     }
  206.     public function setLanguage(?Languages $language): static
  207.     {
  208.         $this->language $language;
  209.         return $this;
  210.     }
  211.     public function getTranslation(): ?self
  212.     {
  213.         return $this->translation;
  214.     }
  215.     public function setTranslation(?self $translation): static
  216.     {
  217.         $this->translation $translation;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, self>
  222.      */
  223.     public function getTranslations(): Collection
  224.     {
  225.         return $this->translations;
  226.     }
  227.     public function addTranslation(self $translation): static
  228.     {
  229.         if (!$this->translations->contains($translation)) {
  230.             $this->translations->add($translation);
  231.             $translation->setTranslation($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeTranslation(self $translation): static
  236.     {
  237.         if ($this->translations->removeElement($translation)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($translation->getTranslation() === $this) {
  240.                 $translation->setTranslation(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245. }