src/Entity/Feedback.php line 31

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Post;
  5. use App\Entity\Traits\CreatedAtTrait;
  6. use App\Entity\Traits\UpdatedAtTrait;
  7. use App\Repository\FeedbackRepository;
  8. use App\State\FeedbackCreateProcessor;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints\Email;
  12. use Symfony\Component\Validator\Constraints\Length;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. #[ORM\HasLifecycleCallbacks]
  15. #[ORM\Entity(repositoryClassFeedbackRepository::class)]
  16. #[ApiResource(
  17.     operations: [
  18.         new Post(
  19.             uriTemplate'/user/feedback',
  20.             denormalizationContext: ['groups' => 'Feedback:create'],
  21.             security"is_granted('ROLE_CLIENT')",
  22.             validationContext: ['groups' => 'Feedback:create'],
  23.             processorFeedbackCreateProcessor::class
  24.         )
  25.     ],
  26.     normalizationContext: ['groups' => 'Feedback:read'],
  27. )]
  28. class Feedback
  29. {
  30.     use CreatedAtTrait;
  31.     use UpdatedAtTrait;
  32.     #[ORM\Id]
  33.     #[ORM\GeneratedValue]
  34.     #[ORM\Column]
  35.     #[Groups(['Feedback:read'])]
  36.     private ?int $id null;
  37.     #[ORM\ManyToOne(inversedBy'feedbacks')]
  38.     #[ORM\JoinColumn(nullablefalse)]
  39.     private ?Client $client null;
  40.     #[ORM\Column(length320)]
  41.     #[NotBlank(groups: ['Feedback:create'])]
  42.     #[Email(groups: ['Feedback:create'])]
  43.     #[Groups(['Feedback:read''Feedback:create'])]
  44.     private ?string $email null;
  45.     #[ORM\Column(length15)]
  46.     #[NotBlank(groups: ['Feedback:create'])]
  47.     #[Length(min10max15groups: ['Feedback:create'])]
  48.     #[Groups(['Feedback:read''Feedback:create'])]
  49.     private ?string $phone null;
  50.     #[ORM\Column(length2048)]
  51.     #[NotBlank(groups: ['Feedback:create'])]
  52.     #[Length(min10max2048groups: ['Feedback:create'])]
  53.     #[Groups(['Feedback:read''Feedback:create'])]
  54.     private ?string $text null;
  55.     #[ORM\Column]
  56.     private ?bool $answer false;
  57.     #[ORM\ManyToOne]
  58.     private ?Admin $staffer null;
  59.     #[ORM\Column(length128)]
  60.     #[NotBlank(groups: ['Feedback:create'])]
  61.     #[Length(min2max128groups: ['Feedback:create'])]
  62.     #[Groups(['Feedback:read''Feedback:create'])]
  63.     private ?string $name null;
  64.     public function getId(): ?int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getClient(): ?Client
  69.     {
  70.         return $this->client;
  71.     }
  72.     public function setClient(?Client $client): self
  73.     {
  74.         $this->client $client;
  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 getPhone(): ?string
  87.     {
  88.         return $this->phone;
  89.     }
  90.     public function setPhone(string $phone): self
  91.     {
  92.         $this->phone $phone;
  93.         return $this;
  94.     }
  95.     public function getText(): ?string
  96.     {
  97.         return $this->text;
  98.     }
  99.     public function setText(string $text): self
  100.     {
  101.         $this->text $text;
  102.         return $this;
  103.     }
  104.     public function isAnswer(): ?bool
  105.     {
  106.         return $this->answer;
  107.     }
  108.     public function setAnswer(bool $answer): self
  109.     {
  110.         $this->answer $answer;
  111.         return $this;
  112.     }
  113.     public function getStaffer(): ?Admin
  114.     {
  115.         return $this->staffer;
  116.     }
  117.     public function setStaffer(?Admin $staffer): self
  118.     {
  119.         $this->staffer $staffer;
  120.         return $this;
  121.     }
  122.     public function getName(): ?string
  123.     {
  124.         return $this->name;
  125.     }
  126.     public function setName(string $name): self
  127.     {
  128.         $this->name $name;
  129.         return $this;
  130.     }
  131. }