src/Entity/Faq.php line 36

Open in your IDE?
  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.     
  71.     public function __construct()
  72.     {
  73.         $this->category = new ArrayCollection();
  74.     }
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getName(): ?string
  80.     {
  81.         return $this->name;
  82.     }
  83.     public function setName(string $name): self
  84.     {
  85.         $this->name $name;
  86.         return $this;
  87.     }
  88.     public function getDate(): ?\DateTimeInterface
  89.     {
  90.         return $this->date;
  91.     }
  92.     public function setDate(\DateTimeInterface $date): self
  93.     {
  94.         $this->date $date;
  95.         return $this;
  96.     }
  97.     public function getContentShort(): ?string
  98.     {
  99.         return $this->contentShort;
  100.     }
  101.     public function setContentShort(?string $contentShort): self
  102.     {
  103.         $this->contentShort $contentShort;
  104.         return $this;
  105.     }
  106.     public function getContentFull(): ?string
  107.     {
  108.         return $this->contentFull;
  109.     }
  110.     public function setContentFull(?string $contentFull): self
  111.     {
  112.         $this->contentFull $contentFull;
  113.         return $this;
  114.     }
  115.     public function getActive(): ?string
  116.     {
  117.         return $this->active;
  118.     }
  119.     public function setActive(string $active): self
  120.     {
  121.         $this->active $active;
  122.         return $this;
  123.     }
  124.     public function getTop(): ?string
  125.     {
  126.         return $this->top;
  127.     }
  128.     public function setTop(?string $top): self
  129.     {
  130.         $this->top $top;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection<int, Category>
  135.      */
  136.     public function getCategory(): Collection
  137.     {
  138.         return $this->category;
  139.     }
  140.     public function addCategory(Category $category): static
  141.     {
  142.         if (!$this->category->contains($category)) {
  143.             $this->category->add($category);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeCategory(Category $category): static
  148.     {
  149.         $this->category->removeElement($category);
  150.         return $this;
  151.     }
  152.     public function getCreatedUser(): ?User
  153.     {
  154.         return $this->createdUser;
  155.     }
  156.     public function setCreatedUser(?User $createdUser): static
  157.     {
  158.         $this->createdUser $createdUser;
  159.         return $this;
  160.     }
  161.     public function getModifiedUser(): ?User
  162.     {
  163.         return $this->modifiedUser;
  164.     }
  165.     public function setModifiedUser(?User $modifiedUser): static
  166.     {
  167.         $this->modifiedUser $modifiedUser;
  168.         return $this;
  169.     }
  170.     public function getDateEntered(): ?\DateTimeInterface
  171.     {
  172.         return $this->dateEntered;
  173.     }
  174.     public function setDateEntered(?\DateTimeInterface $dateEntered): static
  175.     {
  176.         $this->dateEntered $dateEntered;
  177.         return $this;
  178.     }
  179.     public function getDateModified(): ?\DateTimeInterface
  180.     {
  181.         return $this->dateModified;
  182.     }
  183.     public function setDateModified(?\DateTimeInterface $dateModified): static
  184.     {
  185.         $this->dateModified $dateModified;
  186.         return $this;
  187.     }
  188. }