src/Containers/SettingSection/ListContainer/Entities/TariffInsuranceProductEntity.php line 64

Open in your IDE?
  1. <?php
  2. namespace App\Containers\SettingSection\ListContainer\Entities;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use ApiPlatform\Metadata\Delete;
  6. use ApiPlatform\Metadata\Get;
  7. use ApiPlatform\Metadata\Patch;
  8. use ApiPlatform\Metadata\Put;
  9. use ApiPlatform\Metadata\Post;
  10. use ApiPlatform\Metadata\ApiFilter;
  11. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  12. use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
  13. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  14. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\DBAL\Types\Types;
  17. use Gedmo\Mapping\Annotation as Gedmo;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use App\Containers\SettingSection\ListContainer\Data\Repositories\TariffInsuranceProductRepository;
  20. use App\Containers\SettingSection\ListContainer\Entities\InsuranceProductEntity;
  21. /** 
  22.  * Таблица тарифов cтраховых продуктов
  23. */
  24. #[ApiResource(
  25.     routePrefix'/list',
  26.     normalizationContext: ['groups' => 'read'],
  27.     operations: [
  28.         new Get(
  29.             uriTemplate'/insurance_products_tariffs/{id}'requirements: ['id' => '\d+'],
  30.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  31.         ),
  32.         new Patch(
  33.             uriTemplate'/insurance_products_tariffs/{id}'requirements: ['id' => '\d+'],
  34.             security"is_granted('ROLE_ADMIN')"
  35.         ),
  36.         // new Put(
  37.         //     uriTemplate: '/insurance_products_tariffs/{id}', requirements: ['id' => '\d+'],
  38.         //     security: "is_granted('ROLE_ADMIN')"
  39.         // ),
  40.         new Delete(
  41.             uriTemplate'/insurance_products_tariffs/{id}'requirements: ['id' => '\d+'],
  42.             security"is_granted('ROLE_ADMIN')"
  43.         ),
  44.         new Post(
  45.             uriTemplate'/insurance_products_tariffs',
  46.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT')"
  47.         ),
  48.         new GetCollection(
  49.             uriTemplate'/insurance_products_tariffs',
  50.             security"is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
  51.         ),
  52.     ],
  53.     shortName'List_InsuranceProductsTariffs'
  54. )]
  55. #[ApiFilter(SearchFilter::class, properties: ['id' => 'exact''insuranceProduct.name' => 'partial''insuranceProduct.code' => 'partial''insuranceProduct' => 'exact'])]
  56. #[ApiFilter(NumericFilter::class, properties: ['id'])]
  57. #[ApiFilter(RangeFilter::class, properties: ['id''priceFrom''priceUpTo''age1''age2''age3''age4''age5''age6''age7''age8''age9''age10'])]
  58. #[ApiFilter(OrderFilter::class)]
  59. #[ORM\Entity(repositoryClassTariffInsuranceProductRepository::class)]
  60. #[ORM\Table(name'`list_insurance_products_tariffs`')]
  61. class TariffInsuranceProductEntity
  62. {   
  63.     #[ORM\Id]
  64.     #[ORM\GeneratedValue]
  65.     #[ORM\Column(typeTypes::INTEGER)]
  66.     #[Groups(['read'])]
  67.     private ?int $id null;
  68.     // Страховой продукт
  69.     #[ORM\ManyToOne(targetEntityInsuranceProductEntity::class, inversedBy'tariffs')]
  70.     #[ORM\JoinColumn(name'insurance_product_id'referencedColumnName'id'nullablefalse)]
  71.     #[Groups(['read'])]
  72.     private InsuranceProductEntity $insuranceProduct;
  73.     // Стоимость от
  74.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  75.     #[Groups(['read'])]
  76.     private int $priceFrom 0;
  77.     // Стоимость до
  78.     #[ORM\Column(typeTypes::INTEGERoptions: ['default' => 0])]
  79.     #[Groups(['read'])]
  80.     private int $priceUpTo 0;
  81.     // 1 год и меньше
  82.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  83.     #[Groups(['read'])]
  84.     private float $age1 0;
  85.     // 2 года
  86.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  87.     #[Groups(['read'])]
  88.     private float $age2 0;
  89.     // 3 года
  90.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  91.     #[Groups(['read'])]
  92.     private float $age3 0;
  93.     // 4 года
  94.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  95.     #[Groups(['read'])]
  96.     private float $age4 0;
  97.     // 5 лет
  98.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  99.     #[Groups(['read'])]
  100.     private float $age5 0;
  101.     // 6 лет
  102.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  103.     #[Groups(['read'])]
  104.     private float $age6 0;
  105.     // 7 лет
  106.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  107.     #[Groups(['read'])]
  108.     private float $age7 0;
  109.     // 8 лет
  110.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  111.     #[Groups(['read'])]
  112.     private float $age8 0;
  113.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  114.     #[Groups(['read'])]
  115.     private float $age9 0;
  116.     #[ORM\Column(typeTypes::FLOATscale3options: ['default' => 0])]
  117.     #[Groups(['read'])]
  118.     private float $age10 0;
  119.     #[Gedmo\Timestampable(on'create')]
  120.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  121.     protected $createdAt;
  122.     #[Gedmo\Timestampable(on'update')]
  123.     #[ORM\Column(typeTypes::DATETIME_IMMUTABLE)]
  124.     protected $updatedAt;
  125.     public function getId(): ?int
  126.     {
  127.         return $this->id;
  128.     }
  129.     public function getInsuranceProduct()
  130.     {
  131.         return $this->insuranceProduct;
  132.     }
  133.     public function setInsuranceProduct($product)
  134.     {
  135.         $this->insuranceProduct $product;
  136.         return $this;
  137.     }
  138.     public function getPriceFrom()
  139.     {
  140.         return $this->priceFrom;
  141.     }
  142.     public function setPriceFrom($price)
  143.     {
  144.         $this->priceFrom $price;
  145.         return $this;
  146.     }
  147.     public function getPriceUpTo()
  148.     {
  149.         return $this->priceUpTo;
  150.     }
  151.     public function setPriceUpTo($price)
  152.     {
  153.         $this->priceUpTo $price;
  154.         return $this;
  155.     }
  156.     public function getAge1()
  157.     {
  158.         return $this->age1;
  159.     }
  160.     public function setAge1($value)
  161.     {
  162.         $this->age1 = ($value !== null round($value3) : null);
  163.         return $this;
  164.     }
  165.     public function getAge2()
  166.     {
  167.         return $this->age2;
  168.     }
  169.  
  170.     public function setAge2($value)
  171.     {
  172.         $this->age2 = ($value !== null round($value3) : null);
  173.         return $this;
  174.     }
  175.     public function getAge3()
  176.     {
  177.         return $this->age3;
  178.     }
  179.     public function setAge3($value)
  180.     {
  181.         $this->age3 = ($value !== null round($value3) : null);
  182.         return $this;
  183.     }
  184.     public function getAge4()
  185.     {
  186.         return $this->age4;
  187.     }
  188.     public function setAge4($value)
  189.     {
  190.         $this->age4 = ($value !== null round($value3) : null);
  191.         return $this;
  192.     }
  193.     public function getAge5()
  194.     {
  195.         return $this->age5;
  196.     }
  197.     public function setAge5($value)
  198.     {
  199.         $this->age5 = ($value !== null round($value3) : null);
  200.         return $this;
  201.     }
  202.     public function getAge6()
  203.     {
  204.         return $this->age6;
  205.     }
  206.     public function setAge6($value)
  207.     {
  208.         $this->age6 = ($value !== null round($value3) : null);
  209.         return $this;
  210.     }
  211.     public function getAge7()
  212.     {
  213.         return $this->age7;
  214.     }
  215.     public function setAge7($value)
  216.     {
  217.         $this->age7 = ($value !== null round($value3) : null);
  218.         return $this;
  219.     }
  220.     public function getAge8()
  221.     {
  222.         return $this->age8;
  223.     }
  224.     public function setAge8($value)
  225.     {
  226.         $this->age8 = ($value !== null round($value3) : null);
  227.         return $this;
  228.     }
  229.     public function getAge9()
  230.     {
  231.         return $this->age9;
  232.     }
  233.     public function setAge9($value)
  234.     {
  235.         $this->age9 = ($value !== null round($value3) : null);
  236.         return $this;
  237.     }
  238.     public function getAge10()
  239.     {
  240.         return $this->age10;
  241.     }
  242.     public function setAge10($value)
  243.     {
  244.         $this->age10 = ($value !== null round($value3) : null);
  245.         return $this;
  246.     }
  247. }