<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\LepCalculatorPobutRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
//use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
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: LepCalculatorPobutRepository::class)]
#[ApiResource(
normalizationContext: ['groups' => ['calc:read']],
denormalizationContext: ['groups' => ['calc:write']],
order: ['id' => 'ASC'],
)]
//#[ApiFilter(ExistsFilter::class, properties: ['parent_id'])]
#[ApiFilter(SearchFilter::class, properties: ['parent.id' => 'exact', 'maxCount' => 'exact'])]
class LepCalculatorPobut
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['calc:read', 'calc:write'])]
private ?int $id = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\Column(length: 255)]
private ?string $name = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\Column]
private ?int $maxCount = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\Column(nullable: true)]
private ?int $watt = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\Column(nullable: true)]
private ?int $hour = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\Column(nullable: true)]
private ?int $orders = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'lepCalculatorPobuts')]
private ?self $parent = null;
#[Groups(['calc:read', 'calc:write'])]
#[ORM\OneToMany(mappedBy: 'parent', targetEntity: self::class)]
private Collection $lepCalculatorPobuts;
public function __construct()
{
$this->lepCalculatorPobuts = 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 getMaxCount(): ?int
{
return $this->maxCount;
}
public function setMaxCount(int $maxCount): self
{
$this->maxCount = $maxCount;
return $this;
}
public function getWatt(): ?int
{
return $this->watt;
}
public function setWatt(?int $watt): self
{
$this->watt = $watt;
return $this;
}
public function getHour(): ?int
{
return $this->hour;
}
public function setHour(?int $hour): self
{
$this->hour = $hour;
return $this;
}
public function getOrders(): ?int
{
return $this->orders;
}
public function setOrders(?int $orders): self
{
$this->orders = $orders;
return $this;
}
public function getParent(): ?self
{
return $this->parent;
}
public function setParent(?self $parent): self
{
$this->parent = $parent;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getLepCalculatorPobuts(): Collection
{
return $this->lepCalculatorPobuts;
}
public function addLepCalculatorPobut(self $lepCalculatorPobut): self
{
if (!$this->lepCalculatorPobuts->contains($lepCalculatorPobut)) {
$this->lepCalculatorPobuts->add($lepCalculatorPobut);
$lepCalculatorPobut->setParent($this);
}
return $this;
}
public function removeLepCalculatorPobut(self $lepCalculatorPobut): self
{
if ($this->lepCalculatorPobuts->removeElement($lepCalculatorPobut)) {
// set the owning side to null (unless already changed)
if ($lepCalculatorPobut->getParent() === $this) {
$lepCalculatorPobut->setParent(null);
}
}
return $this;
}
}