<?php
namespace App\Containers\SettingSection\ListContainer\Entities;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\NumericFilter;
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Containers\SettingSection\ListContainer\Data\Repositories\TariffKilometersRepository;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
/**
* Тариф километров
*/
#[ApiResource(
routePrefix: '/list',
normalizationContext: ['groups' => 'read'],
operations: [
new Get(
uriTemplate: '/tariff_kilometers/{id}', requirements: ['id' => '\d+'],
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
),
new Patch(
uriTemplate: '/tariff_kilometers/{id}', requirements: ['id' => '\d+'],
security: "is_granted('ROLE_ADMIN')"
),
// new Put(
// uriTemplate: '/tariff_kilometers/{id}', requirements: ['id' => '\d+'],
// security: "is_granted('ROLE_ADMIN')"
// ),
new Delete(
uriTemplate: '/tariff_kilometers/{id}', requirements: ['id' => '\d+'],
security: "is_granted('ROLE_ADMIN')"
),
new Post(
uriTemplate: '/tariff_kilometers',
security: "is_granted('ROLE_ADMIN')"
),
new GetCollection(
uriTemplate: '/tariff_kilometers',
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_USER_CLIENT') or is_granted('ROLE_READONLY')"
),
],
shortName: 'List_TariffKilometers'
)]
#[ApiFilter(SearchFilter::class, properties: ['id' => 'exact'])]
#[ApiFilter(NumericFilter::class, properties: ['id'])]
#[ApiFilter(RangeFilter::class, properties: ['id', 'priceFrom', 'priceUpTo', 'price'])]
#[ApiFilter(OrderFilter::class)]
#[ORM\Entity(repositoryClass: TariffKilometersRepository::class)]
#[ORM\Table(name: '`list_tariff_kilometers`')]
class TariffKilometersEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
#[Groups(['read'])]
private ?int $id = null;
// Стоимость от
#[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
#[Groups(['read'])]
private int $priceFrom = 0;
// Стоимость до
#[ORM\Column(type: Types::INTEGER, options: ['default' => 0])]
#[Groups(['read'])]
private int $priceUpTo = 0;
// 1 год и меньше
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age1 = 0;
// 2 года
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age2 = 0;
// 3 года
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age3 = 0;
// 4 года
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age4 = 0;
// 5 лет
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age5 = 0;
// 6 лет
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age6 = 0;
// 7 лет
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age7 = 0;
// 8 лет
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age8 = 0;
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age9 = 0;
#[ORM\Column(type: Types::FLOAT, scale: 3, options: ['default' => 0])]
#[Groups(['read'])]
private float $age10 = 0;
#[Gedmo\Timestampable(on: 'create')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected $createdAt;
#[Gedmo\Timestampable(on: 'update')]
#[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
protected $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getPriceFrom()
{
return $this->priceFrom;
}
public function setPriceFrom($price)
{
$this->priceFrom = $price;
return $this;
}
public function getPriceUpTo()
{
return $this->priceUpTo;
}
public function setPriceUpTo($price)
{
$this->priceUpTo = $price;
return $this;
}
public function getAge1()
{
return $this->age1;
}
public function setAge1($value)
{
$this->age1 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge2()
{
return $this->age2;
}
public function setAge2($value)
{
$this->age2 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge3()
{
return $this->age3;
}
public function setAge3($value)
{
$this->age3 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge4()
{
return $this->age4;
}
public function setAge4($value)
{
$this->age4 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge5()
{
return $this->age5;
}
public function setAge5($value)
{
$this->age5 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge6()
{
return $this->age6;
}
public function setAge6($value)
{
$this->age6 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge7()
{
return $this->age7;
}
public function setAge7($value)
{
$this->age7 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge8()
{
return $this->age8;
}
public function setAge8($value)
{
$this->age8 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge9()
{
return $this->age9;
}
public function setAge9($value)
{
$this->age9 = ($value !== null ? round($value, 3) : null);
return $this;
}
public function getAge10()
{
return $this->age10;
}
public function setAge10($value)
{
$this->age10 = ($value !== null ? round($value, 3) : null);
return $this;
}
}