src/Entity/InsuredInsurerGlobal.php line 70

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\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Serializer\Annotation\MaxDepth;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. #[ORM\Entity]
  16. #[UniqueEntity(fields: ['insured''insurer'])]
  17. #[ApiResource(
  18.     iri'InsuredInsurerGlobal',
  19.     itemOperations: [
  20.         'get' => [
  21.             // 'security' => "is_granted('ROLE_USER')",
  22.             'normalization_context' => [
  23.                 'groups' => 'insured_insurer_global:item:get',
  24.                 'enable_max_depth' => true
  25.             ]
  26.         ],
  27.         'put' => [
  28.             // 'security' => "is_granted('ROLE_USER')",
  29.             'normalization_context' => [
  30.                 'groups' => 'insured_insurer_global:item:put',
  31.                 'enable_max_depth' => true
  32.             ],
  33.             'denormalization_context' => [
  34.                 'groups' => 'insured_insurer_global:item:put',
  35.                 'enable_max_depth' => true
  36.             ]
  37.         ],
  38.         'delete' => [
  39.             // 'security' => "is_granted('ROLE_USER')",
  40.         ]
  41.     ],
  42.     collectionOperations: [
  43.         'get' => [
  44.             // 'security' => "is_granted('ROLE_USER')",
  45.             'normalization_context' => [
  46.                 'groups' => ['insured_insurer_global:collection:get''createdAt'],
  47.                 'enable_max_depth' => true
  48.             ]
  49.         ],
  50.         'post' => [
  51.             // 'security' => "is_granted('ROLE_USER')",
  52.             'normalization_context' => [
  53.                 'groups' => 'insured_insurer_global:collection:post',
  54.                 'enable_max_depth' => true
  55.             ],
  56.             'denormalization_context' => [
  57.                 'groups' => 'insured_insurer_global:collection:post',
  58.                 'enable_max_depth' => true
  59.             ]
  60.         ],
  61.     ]
  62. )]
  63. #[ApiFilter(SearchFilter::class, properties: [
  64.     'insured' => 'exact',
  65.     'insurer' => 'exact'
  66. ])]
  67. class InsuredInsurerGlobal
  68. {
  69.     use TimestampableEntity;
  70.     
  71.     #[ORM\Id]
  72.     #[ORM\GeneratedValue]
  73.     #[ORM\Column(type'integer')]
  74.     #[Groups([
  75.         'insured_insurer_global:collection:get',
  76.         'insured_insurer_global:item:get',
  77.         'insured:item:get',
  78.     ])]
  79.     private $id;
  80.     #[ORM\Column(type'string'length255nullabletrue)]
  81.     #[Groups([
  82.         'insured_insurer_global:collection:get',
  83.         'insured_insurer_global:item:get',
  84.         'insured:item:get',
  85.     ])]
  86.     private $name;
  87.     #[ORM\ManyToOne(targetEntityInsured::class, inversedBy'insurerGlobals')]
  88.     #[Groups([
  89.         'insured_insurer_global:collection:get',
  90.         'insured_insurer_global:collection:post',
  91.         'insured_insurer_global:item:get',
  92.         'insured_insurer_global:item:put',
  93.         'insurer:collection:post',
  94.     ])]
  95.     #[MaxDepth(1)]
  96.     private $insured;
  97.     #[ORM\ManyToOne(targetEntityInsurer::class, inversedBy'insuredGlobals')]
  98.     #[Groups([
  99.         'insured_insurer_global:collection:get',
  100.         'insured_insurer_global:collection:post',
  101.         'insured_insurer_global:item:get',
  102.         'insured_insurer_global:item:put',
  103.     ])]
  104.     #[MaxDepth(1)]
  105.     private $insurer;
  106.     #[ORM\Column(type'float'nullabletrue)]
  107.     #[Groups([
  108.         'insured_insurer_global:collection:get',
  109.         'insured_insurer_global:collection:post',
  110.         'insured_insurer_global:item:get',
  111.         'insured_insurer_global:item:put',
  112.         'insured:item:get',
  113.         'insured:item:put',
  114.     ])]
  115.     private $approvedLimit;
  116.     #[ORM\Column(type'float'nullabletrue)]
  117.     #[Groups([
  118.         'insured_insurer_global:collection:get',
  119.         'insured_insurer_global:collection:post',
  120.         'insured_insurer_global:item:get',
  121.         'insured_insurer_global:item:put',
  122.         'insured:item:get',
  123.         'insured:item:put',
  124.     ])]
  125.     private $availableLimit;
  126.     #[ORM\Column(type'float'nullabletrue)]
  127.     #[Groups([
  128.         'insured_insurer_global:collection:get',
  129.         'insured_insurer_global:collection:post',
  130.         'insured_insurer_global:item:get',
  131.         'insured_insurer_global:item:put',
  132.         'insured:item:get',
  133.         'insured:item:put',
  134.     ])]
  135.     private $usedLimit;
  136.     #[ORM\Column(type'float'nullabletrue)]
  137.     #[Groups([
  138.         'import:insurer',
  139.         'import:insured',
  140.         'insured_insurer_global:collection:get',
  141.         'insured_insurer_global:collection:post',
  142.         'insured_insurer_global:item:get',
  143.         'insured_insurer_global:item:put',
  144.         'insured:item:get',
  145.         'insured:item:put',
  146.     ])]
  147.     private $comissionRate;
  148.     #[ORM\Column(type'datetime'nullabletrue)]
  149.     #[Groups([
  150.         'import:insurer',
  151.         'import:insured',
  152.         'insured_insurer_global:collection:get',
  153.         'insured_insurer_global:collection:post',
  154.         'insured_insurer_global:item:get',
  155.         'insured_insurer_global:item:put',
  156.         'insured:item:get',
  157.         'insured:item:put',
  158.     ])]
  159.     private $endTime;
  160.     #[ApiProperty()]
  161.     #[Groups([
  162.         'insured:item:get',
  163.         'insured_insurer_global:collection:get',
  164.     ])]
  165.     private $insuredName;
  166.     #[ApiProperty()]
  167.     #[Groups([
  168.         'insured:item:get',
  169.         'insured_insurer_global:collection:get',
  170.     ])]
  171.     private $insurerId;
  172.     #[ApiProperty()]
  173.     #[Groups([
  174.         'insured:item:get',
  175.         'insured_insurer_global:collection:get',
  176.     ])]
  177.     private $insurerName;
  178.     #[ApiProperty()]
  179.     #[Groups([
  180.         'import:insured',
  181.         'insured:item:get',
  182.         'insured_insurer_global:collection:get',
  183.     ])]
  184.     private $insurerTaxID;
  185.     #[ApiProperty()]
  186.     #[Groups([
  187.         'import:insurer',
  188.     ])]
  189.     private $insuredTaxID;
  190.     #[ORM\Column(type'string'nullablefalse)]
  191.     #[ApiProperty(iri'https://schema.org/Text')]
  192.     #[Assert\Type('string')]
  193.     #[Groups([
  194.         'import:insurer',
  195.         'import:insured',
  196.         'insured_insurer_global:collection:get',
  197.         'insured_insurer_global:collection:post',
  198.         'insured_insurer_global:item:get',
  199.         'insured_insurer_global:item:put',
  200.         'insured:item:get',
  201.         'insured:item:put',
  202.     ])]
  203.     private ?string $status null;
  204.     #[ORM\OneToMany(mappedBy'insuredInsurerGlobal'targetEntityInsuredInsurerGlobalCcg::class, cascade: ["persist""remove"], orphanRemovaltrue)]
  205.     #[Groups([
  206.         'insured:item:get',
  207.         'insured_insurer_global:item:get',
  208.     ])]
  209.     #[MaxDepth(1)]
  210.     private $ccgs;
  211.     #[ORM\Column(type'text'nullabletrue)]
  212.     private $observations;
  213.     public function __construct()
  214.     {
  215.         $this->ccgs = new ArrayCollection();
  216.     }
  217.     public function getId(): ?int
  218.     {
  219.         return $this->id;
  220.     }
  221.     public function setName(): void
  222.     {
  223.         $this->name "{$this->getInsuredName()} / {$this->getInsurerName()}";
  224.     }
  225.     public function getName(): ?string
  226.     {
  227.         return $this->name;
  228.     }
  229.     public function getInsured(): ?Insured
  230.     {
  231.         return $this->insured;
  232.     }
  233.     public function setInsured(?Insured $insured): self
  234.     {
  235.         $this->insured $insured;
  236.         return $this;
  237.     }
  238.     public function getInsurer(): ?Insurer
  239.     {
  240.         return $this->insurer;
  241.     }
  242.     public function setInsurer(?Insurer $insurer): self
  243.     {
  244.         $this->insurer $insurer;
  245.         return $this;
  246.     }
  247.     public function getApprovedLimit(): ?float
  248.     {
  249.         return $this->approvedLimit;
  250.     }
  251.     public function setApprovedLimit(?float $approvedLimit): self
  252.     {
  253.         $this->approvedLimit $approvedLimit;
  254.         return $this;
  255.     }
  256.     public function getAvailableLimit(): ?float
  257.     {
  258.         return $this->availableLimit;
  259.     }
  260.     public function setAvailableLimit(?float $availableLimit): self
  261.     {
  262.         $this->availableLimit $availableLimit;
  263.         return $this;
  264.     }
  265.     public function getUsedLimit(): ?float
  266.     {
  267.         return $this->usedLimit;
  268.     }
  269.     public function setUsedLimit(?float $usedLimit): self
  270.     {
  271.         $this->usedLimit $usedLimit;
  272.         return $this;
  273.     }
  274.     public function getComissionRate(): ?float
  275.     {
  276.         return $this->comissionRate;
  277.     }
  278.     public function setComissionRate(?float $comissionRate): self
  279.     {
  280.         $this->comissionRate $comissionRate;
  281.         return $this;
  282.     }
  283.     public function getEndTime(): ?\DateTimeInterface
  284.     {
  285.         return $this->endTime;
  286.     }
  287.     public function setEndTime(?\DateTimeInterface $endTime): self
  288.     {
  289.         $this->endTime $endTime;
  290.         return $this;
  291.     }
  292.     public function getInsuredName(): ?string
  293.     {
  294.         return $this->getInsured()->getName();
  295.     }
  296.     public function getInsurerId(): ?int
  297.     {
  298.         return $this->getInsurer()->getId();
  299.     }
  300.     public function getInsurerName(): ?string
  301.     {
  302.         return $this->getInsurer()->getName();
  303.     }
  304.     public function getInsurerTaxID(): ?string
  305.     {
  306.         return $this->getInsurer()->getTaxID();
  307.     }
  308.     public function getInsuredTaxID(): ?string
  309.     {
  310.         return $this->getInsured()?->getTaxID();
  311.     }
  312.     /**
  313.      * @param string|null $status
  314.      */
  315.     public function setStatus($status): self
  316.     {
  317.         $this->status $status;
  318.         return $this;
  319.     }
  320.     public function getStatus(): ?string
  321.     {
  322.         return $this->status;
  323.     }
  324.     /**
  325.      * @return Collection|InsuredInsurerGlobalCcg[]
  326.      */
  327.     public function getCcgs(): Collection
  328.     {
  329.         return $this->ccgs;
  330.     }
  331.     public function addCcg(InsuredInsurerGlobalCcg $ccg): self
  332.     {
  333.         if (!$this->ccgs->contains($ccg)) {
  334.             $this->ccgs[] = $ccg;
  335.             $ccg->setInsuredInsurerGlobal($this);
  336.         }
  337.         return $this;
  338.     }
  339.     public function removeCcg(InsuredInsurerGlobalCcg $ccg): self
  340.     {
  341.         if ($this->ccgs->removeElement($ccg)) {
  342.             // set the owning side to null (unless already changed)
  343.             if ($ccg->getInsuredInsurerGlobal() === $this) {
  344.                 $ccg->setInsuredInsurerGlobal(null);
  345.             }
  346.         }
  347.         return $this;
  348.     }
  349.     public function getObservations(): ?string
  350.     {
  351.         return $this->observations;
  352.     }
  353.     public function setObservations(?string $observations): self
  354.     {
  355.         $this->observations $observations;
  356.         return $this;
  357.     }
  358. }