<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\CalculatorPriceYurRepository;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Put;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: CalculatorPriceYurRepository::class)]
// #[GetCollection]
// #[Get]
// #[Put(security: "is_granted('ROLE_ADMIN')")]
// #[Post(security: "is_granted('ROLE_ADMIN')")]
// #[Delete(security: "is_granted('ROLE_ADMIN')")]
#[ApiResource(
normalizationContext: ['groups' => ['read']],
denormalizationContext: ['groups' => ['write']],
order: ['id' => 'DESC']
)]
class CalculatorPriceYur
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read', 'write'])]
private ?int $id = null;
#[ORM\Column(length: 10, nullable: true)]
#[Groups(['read', 'write'])]
private ?string $period = null;
#[ORM\ManyToOne(inversedBy: 'calculatorPriceYurs')]
#[Groups(['read', 'write'])]
private ?OperRozp $oper = null;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'write'])]
private ?int $klas = null;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'write'])]
private ?float $priceOne = null;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'write'])]
private ?float $priceTwo = null;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'write'])]
private ?float $priceThree = null;
#[ORM\Column(nullable: true)]
#[Groups(['read', 'write'])]
private ?float $priceFour = null;
public function getId(): ?int
{
return $this->id;
}
public function getPeriod(): ?string
{
return $this->period;
}
public function setPeriod(?string $period): self
{
$this->period = $period;
return $this;
}
public function getOper(): ?OperRozp
{
return $this->oper;
}
public function setOper(?OperRozp $oper): self
{
$this->oper = $oper;
return $this;
}
public function getKlas(): ?int
{
return $this->klas;
}
public function setKlas(?int $klas): self
{
$this->klas = $klas;
return $this;
}
public function getPriceOne(): ?float
{
return $this->priceOne;
}
public function setPriceOne(?float $priceOne): self
{
$this->priceOne = $priceOne;
return $this;
}
public function getPriceTwo(): ?float
{
return $this->priceTwo;
}
public function setPriceTwo(?float $priceTwo): self
{
$this->priceTwo = $priceTwo;
return $this;
}
public function getPriceThree(): ?float
{
return $this->priceThree;
}
public function setPriceThree(?float $priceThree): self
{
$this->priceThree = $priceThree;
return $this;
}
public function getPriceFour(): ?float
{
return $this->priceFour;
}
public function setPriceFour(?float $priceFour): self
{
$this->priceFour = $priceFour;
return $this;
}
/**
* Magic method to get the value of the field with a digit in the name.
*/
public function __get(string $name)
{
// Remove the 'get' prefix and convert the first character to lowercase.
$propertyName = lcfirst(substr($name, 3));
if (property_exists($this, $propertyName)) {
return $this->$propertyName;
}
throw new \InvalidArgumentException("Property '{$name}' does not exist.");
}
/**
* Magic method to set the value of the field with a digit in the name.
*/
public function __set(string $name, $value)
{
// Remove the 'set' prefix and convert the first character to lowercase.
$propertyName = lcfirst(substr($name, 3));
if (property_exists($this, $propertyName)) {
$this->$propertyName = $value;
} else {
throw new \InvalidArgumentException("Property '{$name}' does not exist.");
}
}
}