src/Entity/Form.php line 26

  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.     #[ORM\OneToMany(mappedBy'form'targetEntitySpMethods::class)]
  47.     private Collection $spMethods;
  48.     public function __construct()
  49.     {
  50.         $this->formFields = new ArrayCollection();
  51.         $this->formAnswers = new ArrayCollection();
  52.         $this->spMethods = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getName(): ?string
  59.     {
  60.         return $this->name;
  61.     }
  62.     public function setName(string $name): self
  63.     {
  64.         $this->name $name;
  65.         return $this;
  66.     }
  67.     public function getDate(): ?\DateTimeInterface
  68.     {
  69.         return $this->date;
  70.     }
  71.     public function setDate(?\DateTimeInterface $date): self
  72.     {
  73.         $this->date $date;
  74.         return $this;
  75.     }
  76.     public function getDescription(): ?string
  77.     {
  78.         return $this->description;
  79.     }
  80.     public function setDescription(?string $description): self
  81.     {
  82.         $this->description $description;
  83.         return $this;
  84.     }
  85.     /**
  86.      * @return Collection<int, FormFields>
  87.      */
  88.     public function getFormFields(): Collection
  89.     {
  90.         return $this->formFields;
  91.     }
  92.     public function addFormField(FormFields $formField): self
  93.     {
  94.         if (!$this->formFields->contains($formField)) {
  95.             $this->formFields->add($formField);
  96.             $formField->setForm($this);
  97.         }
  98.         return $this;
  99.     }
  100.     public function removeFormField(FormFields $formField): self
  101.     {
  102.         if ($this->formFields->removeElement($formField)) {
  103.             // set the owning side to null (unless already changed)
  104.             if ($formField->getForm() === $this) {
  105.                 $formField->setForm(null);
  106.             }
  107.         }
  108.         return $this;
  109.     }
  110.     /**
  111.      * @return Collection<int, FormAnswer>
  112.      */
  113.     public function getFormAnswers(): Collection
  114.     {
  115.         return $this->formAnswers;
  116.     }
  117.     public function addFormAnswer(FormAnswer $formAnswer): self
  118.     {
  119.         if (!$this->formAnswers->contains($formAnswer)) {
  120.             $this->formAnswers->add($formAnswer);
  121.             $formAnswer->setForm($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function removeFormAnswer(FormAnswer $formAnswer): self
  126.     {
  127.         if ($this->formAnswers->removeElement($formAnswer)) {
  128.             // set the owning side to null (unless already changed)
  129.             if ($formAnswer->getForm() === $this) {
  130.                 $formAnswer->setForm(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135.     public function getSendMailAnswet(): ?string
  136.     {
  137.         return $this->sendMailAnswet;
  138.     }
  139.     public function setSendMailAnswet(?string $sendMailAnswet): static
  140.     {
  141.         $this->sendMailAnswet $sendMailAnswet;
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return Collection<int, SpMethods>
  146.      */
  147.     public function getSpMethods(): Collection
  148.     {
  149.         return $this->spMethods;
  150.     }
  151.     public function addSpMethod(SpMethods $spMethod): static
  152.     {
  153.         if (!$this->spMethods->contains($spMethod)) {
  154.             $this->spMethods->add($spMethod);
  155.             $spMethod->setForm($this);
  156.         }
  157.         return $this;
  158.     }
  159.     public function removeSpMethod(SpMethods $spMethod): static
  160.     {
  161.         if ($this->spMethods->removeElement($spMethod)) {
  162.             // set the owning side to null (unless already changed)
  163.             if ($spMethod->getForm() === $this) {
  164.                 $spMethod->setForm(null);
  165.             }
  166.         }
  167.         return $this;
  168.     }
  169. }