src/Entity/Endorsement.php line 87

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. use Symfony\Component\Serializer\Annotation\MaxDepth;
  14. /**
  15.  * A demand entity represents the public, not necessarily binding, not necessarily exclusive, announcement by an organization or person to seek a certain type of goods or services. For describing demand using this type, the very same properties used for Offer apply.
  16.  *
  17.  * @see https://schema.org/Demand
  18.  *
  19.  * @author Jordi Fernandes Alves <jfadev@gmail.com>
  20.  */
  21. #[ORM\Entity]
  22. #[ApiResource(
  23.     iri'Endorsement',
  24.     itemOperations: [
  25.         'get' => [
  26.             // 'security' => "is_granted('ROLE_USER')",
  27.             'normalization_context' => [
  28.                 'groups' => 'endorsement:item:get',
  29.                 'enable_max_depth' => true
  30.             ]
  31.         ],
  32.         'put' => [
  33.             // 'security' => "is_granted('ROLE_USER')",
  34.             'normalization_context' => [
  35.                 'groups' => 'endorsement:item:put',
  36.                 'enable_max_depth' => true
  37.             ],
  38.             'denormalization_context' => [
  39.                 'groups' => 'endorsement:item:put',
  40.                 'enable_max_depth' => true
  41.             ]
  42.         ],
  43.         'delete' => [
  44.             // 'security' => "is_granted('ROLE_USER')",
  45.         ]
  46.     ],
  47.     collectionOperations: [
  48.         'get' => [
  49.             // 'security' => "is_granted('ROLE_USER')",
  50.             'normalization_context' => [
  51.                 'groups' => ['endorsement:collection:get''createdAt'],
  52.                 'enable_max_depth' => true
  53.             ]
  54.         ],
  55.         'post' => [
  56.             // 'security' => "is_granted('ROLE_USER')",
  57.             'normalization_context' => [
  58.                 'groups' => 'endorsement:collection:post',
  59.                 'enable_max_depth' => true
  60.             ],
  61.             'denormalization_context' => [
  62.                 'groups' => 'endorsement:collection:post',
  63.                 'enable_max_depth' => true
  64.             ]
  65.         ],
  66.     ]
  67. )]
  68. #[ApiFilter(SearchFilter::class, properties: [
  69.     'policy' => 'exact',
  70.     'endorsementNumber' => 'start',
  71.     'endorsementType' => 'exact',
  72.     'endorsementValue' => 'start',
  73.     'limitValue' => 'start',
  74.     'createdAt' => 'start',
  75. ])]
  76. #[ApiFilter(OrderFilter::class, properties: [
  77.     'endorsementNumber',
  78.     'endorsementType',
  79.     'endorsementValue',
  80.     'limitValue',
  81.     'createdAt'
  82. ])]
  83. class Endorsement
  84. {
  85.     use TimestampableEntity;
  86.     
  87.     #[ORM\Id]
  88.     #[ORM\GeneratedValue(strategy'AUTO')]
  89.     #[ORM\Column(type'integer')]
  90.     #[Groups([
  91.         'endorsement:collection:get',
  92.         'endorsement:collection:post',
  93.         'endorsement:item:get',
  94.         'endorsement:item:put',
  95.     ])]
  96.     private ?int $id null;
  97.     /**
  98.      * @see _:endorsementNumber
  99.      */
  100.     #[ORM\Column(type'string')]
  101.     #[ApiProperty(iri'https://schema.org/Number')]
  102.     #[Assert\Type('string')]
  103.     #[Groups([
  104.         'endorsement:collection:get',
  105.         'endorsement:collection:post',
  106.         'endorsement:item:get',
  107.         'endorsement:item:put',
  108.         'policy:item:get',
  109.     ])]
  110.     private ?string $endorsementNumber null;
  111.     /**
  112.      * The beginning of the availability of the product or service included in the offer.
  113.      *
  114.      * @see https://schema.org/availabilityStarts
  115.      */
  116.     #[ORM\Column(type'date')]
  117.     #[ApiProperty(iri'https://schema.org/availabilityStarts')]
  118.     #[Assert\Type(\DateTimeInterface::class)]
  119.     #[Groups([
  120.         'endorsement:collection:get',
  121.         'endorsement:collection:post',
  122.         'endorsement:item:get',
  123.         'endorsement:item:put',
  124.     ])]
  125.     private ?\DateTimeInterface $availabilityStarts null;
  126.     /**
  127.      * The end of the availability of the product or service included in the offer.
  128.      *
  129.      * @see https://schema.org/availabilityEnds
  130.      */
  131.     #[ORM\Column(type'date')]
  132.     #[ApiProperty(iri'https://schema.org/availabilityEnds')]
  133.     #[Assert\Type(\DateTimeInterface::class)]
  134.     #[Groups([
  135.         'endorsement:collection:get',
  136.         'endorsement:collection:post',
  137.         'endorsement:item:get',
  138.         'endorsement:item:put',
  139.     ])]
  140.     private ?\DateTimeInterface $availabilityEnds null;
  141.     /**
  142.      * @see _:endorsementValue
  143.      */
  144.     #[ORM\Column(type'float')]
  145.     #[ApiProperty(iri'https://schema.org/Number')]
  146.     #[Groups([
  147.         'endorsement:collection:get',
  148.         'endorsement:collection:post',
  149.         'endorsement:item:get',
  150.         'endorsement:item:put',
  151.     ])]
  152.     private ?float $endorsementValue null;
  153.     /**
  154.      * @see _:endorsementType
  155.      */
  156.     #[ORM\Column(type'string')]
  157.     #[ApiProperty(iri'https://schema.org/Text')]
  158.     #[Assert\Type('string')]
  159.     #[Groups([
  160.         'endorsement:collection:get',
  161.         'endorsement:collection:post',
  162.         'endorsement:item:get',
  163.         'endorsement:item:put',
  164.     ])]
  165.     private ?string $endorsementType null;
  166.     #[ORM\Column(type'float')]
  167.     #[ApiProperty(iri'https://schema.org/Number')]
  168.     #[Groups([
  169.         'endorsement:collection:get',
  170.         'endorsement:collection:post',
  171.         'endorsement:item:get',
  172.         'endorsement:item:put',
  173.     ])]
  174.     private ?float $limitValue null;
  175.     /**
  176.      * @see _:observations
  177.      */
  178.     #[ORM\Column(type'text'nullabletrue)]
  179.     #[ApiProperty(iri'https://schema.org/Text')]
  180.     #[Assert\Type('string')]
  181.     #[Groups([
  182.         'endorsement:collection:get',
  183.         'endorsement:collection:post',
  184.         'endorsement:item:get',
  185.         'endorsement:item:put',
  186.     ])]
  187.     private ?string $observations null;
  188.     #[ORM\Column(type'float')]
  189.     #[ApiProperty(iri'https://schema.org/Number')]
  190.     #[Groups([
  191.         'endorsement:collection:get',
  192.         'endorsement:collection:post',
  193.         'endorsement:item:get',
  194.         'endorsement:item:put',
  195.     ])]
  196.     private ?float $eligibleQuantity null;
  197.     #[ORM\Column(type'float')]
  198.     #[ApiProperty(iri'https://schema.org/interestRate')]
  199.     #[Groups([
  200.         'endorsement:collection:get',
  201.         'endorsement:collection:post',
  202.         'endorsement:item:get',
  203.         'endorsement:item:put',
  204.     ])]
  205.     private ?float $interestRate null;
  206.     #[ORM\Column(type'float')]
  207.     #[ApiProperty(iri'https://schema.org/Number')]
  208.     #[Groups([
  209.         'endorsement:collection:get',
  210.         'endorsement:collection:post',
  211.         'endorsement:item:get',
  212.         'endorsement:item:put',
  213.     ])]
  214.     private ?float $insurancePremium null;
  215.     #[ORM\Column(type'float')]
  216.     #[ApiProperty(iri'https://schema.org/Number')]
  217.     #[Groups([
  218.         'endorsement:collection:get',
  219.         'endorsement:collection:post',
  220.         'endorsement:item:get',
  221.         'endorsement:item:put',
  222.     ])]
  223.     private ?float $interestFee null;
  224.     #[ORM\Column(type'float')]
  225.     #[ApiProperty(iri'https://schema.org/Number')]
  226.     #[Groups([
  227.         'endorsement:collection:get',
  228.         'endorsement:collection:post',
  229.         'endorsement:item:get',
  230.         'endorsement:item:put',
  231.     ])]
  232.     private ?float $commission null;
  233.     #[ORM\ManyToOne(targetEntityPolicy::class, inversedBy'endorsements')]
  234.     #[Groups([
  235.         'endorsement:collection:get',
  236.         'endorsement:collection:post',
  237.         'endorsement:item:get',
  238.         'endorsement:item:put',
  239.     ])]
  240.     private $policy;
  241.     #[ORM\OneToOne(inversedBy'endorsement'targetEntityMedia::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  242.     #[Groups([
  243.         'endorsement:collection:get',
  244.         'endorsement:collection:post',
  245.         'endorsement:item:get',
  246.         'endorsement:item:put',
  247.     ])]
  248.     private $upload;
  249.     public function getId(): ?int
  250.     {
  251.         return $this->id;
  252.     }
  253.     /**
  254.      * @param string|null $endorsementNumber
  255.      */
  256.     public function setEndorsementNumber($endorsementNumber): void
  257.     {
  258.         $this->endorsementNumber $endorsementNumber;
  259.     }
  260.     public function getEndorsementNumber(): ?string
  261.     {
  262.         return $this->endorsementNumber;
  263.     }
  264.     public function setAvailabilityStarts(?\DateTimeInterface $availabilityStarts): void
  265.     {
  266.         $this->availabilityStarts $availabilityStarts;
  267.     }
  268.     public function getAvailabilityStarts(): ?\DateTimeInterface
  269.     {
  270.         return $this->availabilityStarts;
  271.     }
  272.     public function setAvailabilityEnds(?\DateTimeInterface $availabilityEnds): void
  273.     {
  274.         $this->availabilityEnds $availabilityEnds;
  275.     }
  276.     public function getAvailabilityEnds(): ?\DateTimeInterface
  277.     {
  278.         return $this->availabilityEnds;
  279.     }
  280.     /**
  281.      * @param float|null $endorsementValue
  282.      */
  283.     public function setEndorsementValue($endorsementValue): void
  284.     {
  285.         $this->endorsementValue $endorsementValue;
  286.     }
  287.     public function getEndorsementValue(): ?float
  288.     {
  289.         return $this->endorsementValue;
  290.     }
  291.     /**
  292.      * @param string|null $endorsementType
  293.      */
  294.     public function setEndorsementType($endorsementType): void
  295.     {
  296.         $this->endorsementType $endorsementType;
  297.     }
  298.     public function getEndorsementType(): ?string
  299.     {
  300.         return $this->endorsementType;
  301.     }
  302.     /**
  303.      * @param string|null $observations
  304.      */
  305.     public function setObservations($observations): void
  306.     {
  307.         $this->observations $observations;
  308.     }
  309.     public function getObservations(): ?string
  310.     {
  311.         return $this->observations;
  312.     }
  313.     /**
  314.      * @param float|null $eligibleQuantity
  315.      */
  316.     public function setEligibleQuantity($eligibleQuantity): void
  317.     {
  318.         $this->eligibleQuantity $eligibleQuantity;
  319.     }
  320.     public function getEligibleQuantity(): ?float
  321.     {
  322.         return $this->eligibleQuantity;
  323.     }
  324.     /**
  325.      * @param float|null $interestRate
  326.      */
  327.     public function setInterestRate($interestRate): void
  328.     {
  329.         $this->interestRate $interestRate;
  330.     }
  331.     public function getInterestRate(): ?float
  332.     {
  333.         return $this->interestRate;
  334.     }
  335.     /**
  336.      * @param float|null $insurancePremium
  337.      */
  338.     public function setInsurancePremium($insurancePremium): void
  339.     {
  340.         $this->insurancePremium $insurancePremium;
  341.     }
  342.     public function getInsurancePremium(): ?float
  343.     {
  344.         return $this->insurancePremium;
  345.     }
  346.     /**
  347.      * @param float|null $interestFee
  348.      */
  349.     public function setInterestFee($interestFee): void
  350.     {
  351.         $this->interestFee $interestFee;
  352.     }
  353.     public function getInterestFee(): ?float
  354.     {
  355.         return $this->interestFee;
  356.     }
  357.     /**
  358.      * @param float|null $commission
  359.      */
  360.     public function setCommission($commission): void
  361.     {
  362.         $this->commission $commission;
  363.     }
  364.     public function getCommission(): ?float
  365.     {
  366.         return $this->commission;
  367.     }
  368.     public function getPolicy(): ?Policy
  369.     {
  370.         return $this->policy;
  371.     }
  372.     public function setPolicy(?Policy $policy): self
  373.     {
  374.         $this->policy $policy;
  375.         return $this;
  376.     }
  377.     public function getUpload(): ?Media
  378.     {
  379.         return $this->upload;
  380.     }
  381.     public function setUpload(?Media $upload): self
  382.     {
  383.         $this->upload $upload;
  384.         return $this;
  385.     }
  386.     public function getLimitValue(): ?float
  387.     {
  388.         return $this->limitValue;
  389.     }
  390.     public function setLimitValue(?float $limitValue): self
  391.     {
  392.         $this->limitValue $limitValue;
  393.         return $this;
  394.     }
  395. }