src/Containers/SettingSection/ListContainer/Entities/TariffKilometersEntity.php line 63

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