src/Entity/Form.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\FormRepository;
  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 Symfony\Component\Serializer\Annotation\Groups;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. #[ORM\Entity(repositoryClassFormRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['form:read']],
  15.     denormalizationContext: ['groups' => ['form:write']],
  16.     order: ['id' => 'DESC']
  17. )]
  18. #[ApiFilter(SearchFilter::class, properties: [
  19.     'id' => 'exact'
  20.     'name' => 'partial' 
  21. ])]
  22. class Form
  23. {
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     #[Groups(['form:read''form:write''formAnswer:read''formAnswer:write'])]
  28.     private ?int $id null;
  29.     #[ORM\Column(length255)]
  30.     #[Groups(['form:read''form:write''formAnswer:read''formAnswer:write'])]
  31.     private ?string $name null;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  33.     #[Groups(['form:read''form:write''formAnswer:read''formAnswer:write'])]
  34.     private ?\DateTimeInterface $date null;
  35.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  36.     #[Groups(['form:read''form:write''formAnswer:read''formAnswer:write'])]
  37.     private ?string $description null;
  38.     #[ORM\OneToMany(mappedBy'form'targetEntityFormFields::class, cascade:['persist''remove'])]
  39.     #[Groups(['form:read''form:write''formAnswer:read''formAnswer:write'])]
  40.     private Collection $formFields;
  41.     #[ORM\OneToMany(mappedBy'form'targetEntityFormAnswer::class)]
  42.     private Collection $formAnswers;
  43.     #[ORM\Column(length255nullabletrue)]
  44.     #[Groups(['form:read''form:write''formAnswer:read''formAnswer:write'])]
  45.     private ?string $sendMailAnswet null;
  46.     public function __construct()
  47.     {
  48.         $this->formFields = new ArrayCollection();
  49.         $this->formAnswers = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getDate(): ?\DateTimeInterface
  65.     {
  66.         return $this->date;
  67.     }
  68.     public function setDate(?\DateTimeInterface $date): self
  69.     {
  70.         $this->date $date;
  71.         return $this;
  72.     }
  73.     public function getDescription(): ?string
  74.     {
  75.         return $this->description;
  76.     }
  77.     public function setDescription(?string $description): self
  78.     {
  79.         $this->description $description;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, FormFields>
  84.      */
  85.     public function getFormFields(): Collection
  86.     {
  87.         return $this->formFields;
  88.     }
  89.     public function addFormField(FormFields $formField): self
  90.     {
  91.         if (!$this->formFields->contains($formField)) {
  92.             $this->formFields->add($formField);
  93.             $formField->setForm($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeFormField(FormFields $formField): self
  98.     {
  99.         if ($this->formFields->removeElement($formField)) {
  100.             // set the owning side to null (unless already changed)
  101.             if ($formField->getForm() === $this) {
  102.                 $formField->setForm(null);
  103.             }
  104.         }
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, FormAnswer>
  109.      */
  110.     public function getFormAnswers(): Collection
  111.     {
  112.         return $this->formAnswers;
  113.     }
  114.     public function addFormAnswer(FormAnswer $formAnswer): self
  115.     {
  116.         if (!$this->formAnswers->contains($formAnswer)) {
  117.             $this->formAnswers->add($formAnswer);
  118.             $formAnswer->setForm($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeFormAnswer(FormAnswer $formAnswer): self
  123.     {
  124.         if ($this->formAnswers->removeElement($formAnswer)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($formAnswer->getForm() === $this) {
  127.                 $formAnswer->setForm(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getSendMailAnswet(): ?string
  133.     {
  134.         return $this->sendMailAnswet;
  135.     }
  136.     public function setSendMailAnswet(?string $sendMailAnswet): static
  137.     {
  138.         $this->sendMailAnswet $sendMailAnswet;
  139.         return $this;
  140.     }
  141. }