<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\OperRozpRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
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: OperRozpRepository::class)]
#[Get]
#[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 OperRozp
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read', 'write'])]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['read', 'write'])]
private ?string $name = null;
#[ORM\Column(nullable: true)]
private ?int $orders = null;
#[ORM\Column(nullable: true)]
private ?int $active = null;
#[ORM\OneToMany(mappedBy: 'oper', targetEntity: CalculatorPriceYur::class)]
private Collection $calculatorPriceYurs;
public function __construct()
{
$this->calculatorPriceYurs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getOrders(): ?int
{
return $this->orders;
}
public function setOrders(?int $orders): self
{
$this->orders = $orders;
return $this;
}
public function getActive(): ?int
{
return $this->active;
}
public function setActive(?int $active): self
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, CalculatorPriceYur>
*/
public function getCalculatorPriceYurs(): Collection
{
return $this->calculatorPriceYurs;
}
public function addCalculatorPriceYur(CalculatorPriceYur $calculatorPriceYur): self
{
if (!$this->calculatorPriceYurs->contains($calculatorPriceYur)) {
$this->calculatorPriceYurs->add($calculatorPriceYur);
$calculatorPriceYur->setOper($this);
}
return $this;
}
public function removeCalculatorPriceYur(CalculatorPriceYur $calculatorPriceYur): self
{
if ($this->calculatorPriceYurs->removeElement($calculatorPriceYur)) {
// set the owning side to null (unless already changed)
if ($calculatorPriceYur->getOper() === $this) {
$calculatorPriceYur->setOper(null);
}
}
return $this;
}
}