src/Entity/InsuredSubmitInsurers.php line 70

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use ApiPlatform\Core\Annotation\ApiFilter;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  8. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  9. use App\Trait\TimestampableEntity;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ORM\Entity]
  14. #[ApiResource(
  15.     iri'InsuredSubmitInsurers',
  16.     itemOperations: [
  17.         'get' => [
  18.             // 'security' => "is_granted('ROLE_USER')",
  19.             'normalization_context' => [
  20.                 'groups' => 'insured_submit_insurers:item:get',
  21.                 'enable_max_depth' => true
  22.             ]
  23.         ],
  24.         'put' => [
  25.             // 'security' => "is_granted('ROLE_USER')",
  26.             'normalization_context' => [
  27.                 'groups' => 'insured_submit_insurers:item:put',
  28.                 'enable_max_depth' => true
  29.             ],
  30.             'denormalization_context' => [
  31.                 'groups' => 'insured_submit_insurers:item:put',
  32.                 'enable_max_depth' => true
  33.             ]
  34.         ],
  35.         'delete' => [
  36.             // 'security' => "is_granted('ROLE_USER')",
  37.         ]
  38.     ],
  39.     collectionOperations: [
  40.         'get' => [
  41.             // 'security' => "is_granted('ROLE_USER')",
  42.             'normalization_context' => [
  43.                 'groups' => ['insured_submit_insurers:collection:get''createdAt'],
  44.                 'enable_max_depth' => true
  45.             ]
  46.         ],
  47.         'post' => [
  48.             // 'security' => "is_granted('ROLE_USER')",
  49.             'normalization_context' => [
  50.                 'groups' => 'insured_submit_insurers:collection:post',
  51.                 'enable_max_depth' => true
  52.             ],
  53.             'denormalization_context' => [
  54.                 'groups' => 'insured_submit_insurers:collection:post',
  55.                 'enable_max_depth' => true
  56.             ]
  57.         ],
  58.     ]
  59. )]
  60. #[ApiFilter(SearchFilter::class, properties: [
  61.     'insured' => 'exact',
  62. ])]
  63. #[ApiFilter(OrderFilter::class, properties: [
  64.     'createdAt'
  65. ])]
  66. class InsuredSubmitInsurers
  67. {
  68.     use TimestampableEntity;
  69.     
  70.     #[ORM\Id]
  71.     #[ORM\GeneratedValue(strategy'AUTO')]
  72.     #[ORM\Column(type'integer')]
  73.     #[Groups([
  74.         'insured_submit_insurers:collection:get',
  75.         'insured_submit_insurers:collection:post',
  76.         'insured_submit_insurers:item:get',
  77.         'insured_submit_insurers:item:put',
  78.     ])]
  79.     private ?int $id null;
  80.     #[ORM\Column(type'string'nullablefalse)]
  81.     #[ApiProperty(iri'https://schema.org/Text')]
  82.     #[Assert\Type('string')]
  83.     #[Groups([
  84.         'insured_submit_insurers:collection:get',
  85.         'insured_submit_insurers:collection:post',
  86.         'insured_submit_insurers:item:get',
  87.         'insured_submit_insurers:item:put',
  88.     ])]
  89.     private ?string $subject null;
  90.     #[ORM\Column(type'text'nullablefalse)]
  91.     #[ApiProperty(iri'https://schema.org/Text')]
  92.     #[Groups([
  93.         'insured_submit_insurers:collection:get',
  94.         'insured_submit_insurers:collection:post',
  95.         'insured_submit_insurers:item:get',
  96.         'insured_submit_insurers:item:put',
  97.     ])]
  98.     private ?string $message null;
  99.     #[ORM\Column(type'json')]
  100.     #[ApiProperty()]
  101.     #[Groups([
  102.         'insured_submit_insurers:collection:get',
  103.         'insured_submit_insurers:collection:post',
  104.         'insured_submit_insurers:item:get',
  105.         'insured_submit_insurers:item:put',
  106.     ])]
  107.     private array $recipients = [];
  108.     #[ORM\Column(type'json')]
  109.     #[ApiProperty()]
  110.     #[Groups([
  111.         'insured_submit_insurers:collection:get',
  112.         'insured_submit_insurers:collection:post',
  113.         'insured_submit_insurers:item:get',
  114.         'insured_submit_insurers:item:put',
  115.     ])]
  116.     private array $attachments = [];
  117.     #[ORM\ManyToOne(targetEntityInsured::class/*, inversedBy: 'submits'*/)]
  118.     #[Groups([
  119.         'insured_submit_insurers:collection:get',
  120.         'insured_submit_insurers:collection:post',
  121.         'insured_submit_insurers:item:get',
  122.         'insured_submit_insurers:item:put',
  123.     ])]
  124.     private $insured;
  125.     #[ORM\Column(type'string'nullablefalse)]
  126.     #[ApiProperty(iri'https://schema.org/Text')]
  127.     #[Assert\Type('string')]
  128.     #[Groups([
  129.         'insured_submit_insurers:collection:get',
  130.         'insured_submit_insurers:collection:post',
  131.         'insured_submit_insurers:item:get',
  132.         'insured_submit_insurers:item:put',
  133.     ])]
  134.     private ?string $status 'pending';
  135.     public function getId(): ?int
  136.     {
  137.         return $this->id;
  138.     }
  139.     public function getInsured(): ?Insured
  140.     {
  141.         return $this->insured;
  142.     }
  143.     public function setInsured(?Insured $insured): self
  144.     {
  145.         $this->insured $insured;
  146.         return $this;
  147.     }
  148.     public function getSubject(): ?string
  149.     {
  150.         return $this->subject;
  151.     }
  152.     public function setSubject(?string $subject): self
  153.     {
  154.         $this->subject $subject;
  155.         return $this;
  156.     }
  157.     public function getMessage(): ?string
  158.     {
  159.         return $this->message;
  160.     }
  161.     public function setMessage(?string $message): self
  162.     {
  163.         $this->message $message;
  164.         return $this;
  165.     }
  166.     public function getRecipients(): array
  167.     {
  168.         $recipients $this->recipients;
  169.         return array_unique($recipients);
  170.     }
  171.     public function setRecipients(array $recipients): self
  172.     {
  173.         $this->recipients $recipients;
  174.         return $this;
  175.     }
  176.     public function getAttachments(): array
  177.     {
  178.         $attachments $this->attachments;
  179.         return array_unique($attachments);
  180.     }
  181.     public function setAttachments(array $attachments): self
  182.     {
  183.         $this->attachments $attachments;
  184.         return $this;
  185.     }
  186.     
  187.     public function setStatus($status): self
  188.     {
  189.         $this->status $status;
  190.         return $this;
  191.     }
  192.     public function getStatus(): ?string
  193.     {
  194.         return $this->status;
  195.     }
  196. }