src/Entity/ContactSubmission.php line 32

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Serializer\Annotation\Groups,
  6.     Symfony\Component\Validator\Constraints as Assert;
  7. use ApiPlatform\Metadata\ApiResource,
  8.     ApiPlatform\Metadata\ApiProperty,
  9.     ApiPlatform\Metadata\Get,
  10.     ApiPlatform\Metadata\GetCollection;
  11. use App\Entity\Trait\IdTrait,
  12.     App\Entity\Trait\UuidTrait,
  13.     App\Entity\Trait\TimestampableTrait,
  14.     App\Repository\ContactSubmissionRepository;
  15. #[ApiResource(
  16.     description'Contact submissions',
  17.     normalizationContext: ['groups' => ['read''read:' self::class]],
  18.     security'is_granted("' self::class . '")',
  19.     order: ['createdAt' => 'desc'],
  20.     operations: [
  21.         new GetCollection(),
  22.         new Get(),
  23.     ],
  24.     extraProperties: ['standard_put' => false],
  25. )]
  26. #[ORM\Entity(repositoryClassContactSubmissionRepository::class)]
  27. class ContactSubmission
  28. {
  29.     use IdTrait,
  30.         UuidTrait,
  31.         TimestampableTrait;
  32.     #[ApiProperty(description'Subject')]
  33.     #[Groups(['read:' self::class])]
  34.     #[ORM\ManyToOne(targetEntityContactSubject::class)]
  35.     #[ORM\JoinColumn(onDelete'set null')]
  36.     private ?ContactSubject $subject null;
  37.     #[ApiProperty(description'Full name')]
  38.     #[Groups(['read:' self::class])]
  39.     #[Assert\NotBlank]
  40.     #[ORM\Column(typeTypes::STRINGlength511)]
  41.     private string $fullName;
  42.     #[ApiProperty(description'E-mail')]
  43.     #[Groups(['read:' self::class])]
  44.     #[Assert\NotBlank]
  45.     #[Assert\Email]
  46.     #[ORM\Column(typeTypes::STRINGlength255)]
  47.     private string $email;
  48.     #[ApiProperty(description'Description')]
  49.     #[Groups(['read:' self::class])]
  50.     #[Assert\NotBlank]
  51.     #[ORM\Column(typeTypes::TEXT)]
  52.     private string $description;
  53.     public function __construct()
  54.     {
  55.         $this->setUuid();
  56.         $this->createdAt = new \DateTimeImmutable();
  57.         $this->updatedAt = new \DateTimeImmutable();
  58.     }
  59.     public function getSubject(): ?ContactSubject
  60.     {
  61.         return $this->subject;
  62.     }
  63.     public function setSubject(ContactSubject $subject): self
  64.     {
  65.         $this->subject $subject;
  66.         return $this;
  67.     }
  68.     public function getFullName(): string
  69.     {
  70.         return $this->fullName;
  71.     }
  72.     public function setFullName(string $fullName): self
  73.     {
  74.         $this->fullName $fullName;
  75.         return $this;
  76.     }
  77.     public function getEmail(): string
  78.     {
  79.         return $this->email;
  80.     }
  81.     public function setEmail(string $email): self
  82.     {
  83.         $this->email $email;
  84.         return $this;
  85.     }
  86.     public function getDescription(): string
  87.     {
  88.         return $this->description;
  89.     }
  90.     public function setDescription(string $description): self
  91.     {
  92.         $this->description $description;
  93.         return $this;
  94.     }
  95. }