src/Entity/FAQ.php line 26

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\Get;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use App\Controller\Api\Controller\Faq\FaqCourseController;
  7. use App\Repository\FAQRepository;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. #[ORM\Entity(repositoryClassFAQRepository::class)]
  12. #[ApiResource(
  13.     operations: [
  14.         new GetCollection(
  15.             normalizationContext:['groups' => ['read:faq:collection']],
  16.             name'course_faq',
  17.             uriTemplate'/cours/{id}/faqs',
  18.             controllerFaqCourseController::class,
  19.         )
  20.     ],
  21.     normalizationContext: ['groups' => ['read:faq:collection']]
  22. )]
  23. class FAQ
  24. {
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     #[Groups(['read:course:item''read:faq:collection'])]
  29.     private ?int $id null;
  30.     #[ORM\ManyToOne(inversedBy'fAQs'cascade: ['persist'])]
  31.     #[ORM\JoinColumn(nullablefalse)]
  32.     private ?Cours $cours null;
  33.     #[ORM\Column(typeTypes::TEXT)]
  34.     #[Groups(['read:course:item''read:faq:collection'])]
  35.     private ?string $question null;
  36.     #[ORM\Column(typeTypes::TEXT)]
  37.     #[Groups(['read:course:item''read:faq:collection'])]
  38.     private ?string $answer null;
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getCours(): ?Cours
  44.     {
  45.         return $this->cours;
  46.     }
  47.     public function setCours(?Cours $cours): self
  48.     {
  49.         $this->cours $cours;
  50.         return $this;
  51.     }
  52.     public function getQuestion(): ?string
  53.     {
  54.         return $this->question;
  55.     }
  56.     public function setQuestion(string $question): self
  57.     {
  58.         $this->question $question;
  59.         return $this;
  60.     }
  61.     public function getAnswer(): ?string
  62.     {
  63.         return $this->answer;
  64.     }
  65.     public function setAnswer(string $answer): self
  66.     {
  67.         $this->answer $answer;
  68.         return $this;
  69.     }
  70. }