src/Entity/Faq.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Repository\FaqRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Ramsey\Uuid\Doctrine\UuidGenerator;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Symfony\Component\Serializer\Annotation\SerializedName;
  11. /**
  12.  * @ApiResource(
  13.  *     attributes={
  14.  *          "pagination_items_per_page"=50,
  15.  *          "normalization_context"={"groups"={
  16.  *              "Faq:output",
  17.  *              "Faq:io"
  18.  *          }},
  19.  *          "denormalization_context"={"groups"={
  20.  *              "Faq:input",
  21.  *              "Faq:io"
  22.  *          }},
  23.  *         "order"={"position": "ASC"},
  24.  *      },
  25.  *     collectionOperations={
  26.  *          "get"={
  27.  *              "method"="GET",
  28.  *              "path"="/public/faqs",
  29.  *          }
  30.  *     },
  31.  *     itemOperations={
  32.  *          "get"={
  33.  *              "method"="GET"
  34.  *          },
  35.  *      }
  36.  * )
  37.  *
  38.  * @ORM\Entity(repositoryClass=FaqRepository::class)
  39.  */
  40. class Faq
  41. {
  42.     /**
  43.      * Hook timestampable behavior
  44.      * updates createdAt, updatedAt fields
  45.      */
  46.     use TimestampableEntity;
  47.     /**
  48.      * @ORM\Id
  49.      * @ORM\Column(type="uuid", unique=true)
  50.      * @ORM\GeneratedValue(strategy="CUSTOM")
  51.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  52.      * @SerializedName("id")
  53.      * @ApiProperty(identifier=true)
  54.      * @Groups({"Faq:output"})
  55.      */
  56.     private string $id;
  57.     /**
  58.      * @ORM\Column(type="string", length=255)
  59.      * @SerializedName("question")
  60.      * @Groups({"Faq:output"})
  61.      */
  62.     private ?string $question;
  63.     /**
  64.      * @ORM\Column(type="text")
  65.      * @SerializedName("answer")
  66.      * @Groups({"Faq:output"})
  67.      */
  68.     private ?string $answer;
  69.     /**
  70.      * @ORM\Column(type="integer", options={"default": 0})
  71.      * @SerializedName("position")
  72.      * @Groups({"Faq:output"})
  73.      */
  74.     private ?int $position;
  75.     /**
  76.      * @return string
  77.      */
  78.     public function getId(): ?string
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function getQuestion(): ?string
  83.     {
  84.         return $this->question;
  85.     }
  86.     public function setQuestion(string $question): self
  87.     {
  88.         $this->question $question;
  89.         return $this;
  90.     }
  91.     public function getAnswer(): ?string
  92.     {
  93.         return $this->answer;
  94.     }
  95.     public function setAnswer(string $answer): self
  96.     {
  97.         $this->answer $answer;
  98.         return $this;
  99.     }
  100.     public function getPosition(): ?int
  101.     {
  102.         return $this->position;
  103.     }
  104.     public function setPosition(?int $position): Faq
  105.     {
  106.         $this->position $position;
  107.         return $this;
  108.     }
  109. }