src/Entity/InsurerModality.php line 68

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiProperty;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Annotation\ApiFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use App\Trait\TimestampableEntity;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Serializer\Annotation\MaxDepth;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. #[ORM\Entity]
  14. #[UniqueEntity(fields: ['insurer''modality'])]
  15. #[ApiResource(
  16.     iri'InsurerModality',
  17.     itemOperations: [
  18.         'get' => [
  19.             // 'security' => "is_granted('ROLE_USER')",
  20.             'normalization_context' => [
  21.                 'groups' => 'insurer_modality:item:get',
  22.                 'enable_max_depth' => true
  23.             ]
  24.         ],
  25.         'put' => [
  26.             // 'security' => "is_granted('ROLE_USER')",
  27.             'normalization_context' => [
  28.                 'groups' => 'insurer_modality:item:put',
  29.                 'enable_max_depth' => true
  30.             ],
  31.             'denormalization_context' => [
  32.                 'groups' => 'insurer_modality:item:put',
  33.                 'enable_max_depth' => true
  34.             ]
  35.         ],
  36.         'delete' => [
  37.             // 'security' => "is_granted('ROLE_USER')",
  38.         ]
  39.     ],
  40.     collectionOperations: [
  41.         'get' => [
  42.             // 'security' => "is_granted('ROLE_USER')",
  43.             'normalization_context' => [
  44.                 'groups' => ['insurer_modality:collection:get''createdAt'],
  45.                 'enable_max_depth' => true
  46.             ]
  47.         ],
  48.         'post' => [
  49.             // 'security' => "is_granted('ROLE_USER')",
  50.             'normalization_context' => [
  51.                 'groups' => 'insurer_modality:collection:post',
  52.                 'enable_max_depth' => true
  53.             ],
  54.             'denormalization_context' => [
  55.                 'groups' => 'insurer_modality:collection:post',
  56.                 'enable_max_depth' => true
  57.             ]
  58.         ],
  59.     ]
  60. )]
  61. #[ApiFilter(SearchFilter::class, properties: [
  62.     'modality' => 'exact',
  63.     'insurer' => 'exact'
  64. ])]
  65. class InsurerModality
  66. {
  67.     use TimestampableEntity;
  68.     
  69.     #[ORM\Id]
  70.     #[ORM\GeneratedValue]
  71.     #[ORM\Column(type'integer')]
  72.     #[Groups([
  73.         'insurer_modality:collection:get',
  74.         'insurer_modality:item:get',
  75.     ])]
  76.     private $id;
  77.     #[ORM\Column(type'float'nullabletrue)]
  78.     #[Groups([
  79.         'import:insurer',
  80.         'insurer_modality:collection:get',
  81.         'insurer_modality:collection:post',
  82.         'insurer_modality:item:get',
  83.         'insurer_modality:item:put',
  84.         'insurer:item:get',
  85.         'insurer:item:put',
  86.     ])]
  87.     private $limitValue;
  88.     #[ORM\ManyToOne(targetEntityInsurer::class, inversedBy'modalities')]
  89.     #[Groups([
  90.         'insurer_modality:collection:get',
  91.         'insurer_modality:collection:post',
  92.         'insurer_modality:item:get',
  93.         'insurer_modality:item:put',
  94.     ])]
  95.     #[MaxDepth(1)]
  96.     private $insurer;
  97.     #[ORM\ManyToOne(targetEntityModality::class, inversedBy'insurers')]
  98.     #[Groups([
  99.         'insurer_modality:collection:get',
  100.         'insurer_modality:collection:post',
  101.         'insurer_modality:item:get',
  102.         'insurer_modality:item:put',
  103.         'insurer:item:get',
  104.     ])]
  105.     #[MaxDepth(1)]
  106.     private $modality;
  107.     #[ORM\Column(type'boolean')]
  108.     #[Assert\Type('boolean')]
  109.     #[Groups([
  110.         'import:insurer',
  111.         'insurer_modality:collection:get',
  112.         'insurer_modality:collection:post',
  113.         'insurer_modality:item:get',
  114.         'insurer_modality:item:put',
  115.         'insurer:item:get',
  116.         'insurer:item:put',
  117.     ])]
  118.     private bool $isSelected false;
  119.     #[ApiProperty()]
  120.     #[Groups([
  121.         'import:insurer',
  122.         'insurer_modality:collection:get',
  123.         'insurer:item:get',
  124.     ])]
  125.     private $modalityName;
  126.     public function getId(): ?int
  127.     {
  128.         return $this->id;
  129.     }
  130.     public function getLimitValue(): ?float
  131.     {
  132.         return $this->limitValue;
  133.     }
  134.     public function setLimitValue(?float $limitValue): self
  135.     {
  136.         $this->limitValue $limitValue;
  137.         return $this;
  138.     }
  139.     public function getInsurer(): ?Insurer
  140.     {
  141.         return $this->insurer;
  142.     }
  143.     public function setInsurer(?Insurer $insurer): self
  144.     {
  145.         $this->insurer $insurer;
  146.         return $this;
  147.     }
  148.     public function getModality(): ?Modality
  149.     {
  150.         return $this->modality;
  151.     }
  152.     public function setModality(?Modality $modality): self
  153.     {
  154.         $this->modality $modality;
  155.         return $this;
  156.     }
  157.     public function setIsSelected($isSelected): self
  158.     {
  159.         $this->isSelected $isSelected;
  160.         return $this;
  161.     }
  162.     public function getIsSelected(): ?bool
  163.     {
  164.         return $this->isSelected;
  165.     }
  166.     public function getModalityName(): ?string
  167.     {
  168.         return $this->getModality()->getName();
  169.     }
  170. }