src/Entity/LepCalculatorPobut.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\LepCalculatorPobutRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use ApiPlatform\Metadata\ApiFilter;
  9. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  10. //use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
  11. use ApiPlatform\Metadata\Post;
  12. use ApiPlatform\Metadata\Get;
  13. use ApiPlatform\Metadata\Delete;
  14. use ApiPlatform\Metadata\Put;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. #[ORM\Entity(repositoryClassLepCalculatorPobutRepository::class)]
  17. #[ApiResource(
  18.     normalizationContext: ['groups' => ['calc:read']],
  19.     denormalizationContext: ['groups' => ['calc:write']],
  20.     order: ['id' => 'ASC'],
  21. )]
  22. //#[ApiFilter(ExistsFilter::class, properties: ['parent_id'])]
  23. #[ApiFilter(SearchFilter::class, properties: ['parent.id' => 'exact''maxCount' => 'exact'])]
  24. class LepCalculatorPobut
  25. {
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column]
  29.     #[Groups(['calc:read''calc:write'])]
  30.     private ?int $id null;
  31.     #[Groups(['calc:read''calc:write'])]
  32.     #[ORM\Column(length255)]
  33.     private ?string $name null;
  34.     #[Groups(['calc:read''calc:write'])]
  35.     #[ORM\Column]
  36.     private ?int $maxCount null;
  37.     #[Groups(['calc:read''calc:write'])]
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $watt null;
  40.     #[Groups(['calc:read''calc:write'])]
  41.     #[ORM\Column(nullabletrue)]
  42.     private ?int $hour null;
  43.     #[Groups(['calc:read''calc:write'])]
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?int $orders null;
  46.     #[Groups(['calc:read''calc:write'])]
  47.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'lepCalculatorPobuts')]
  48.     private ?self $parent null;
  49.     #[Groups(['calc:read''calc:write'])]
  50.     #[ORM\OneToMany(mappedBy'parent'targetEntityself::class)]
  51.     private Collection $lepCalculatorPobuts;
  52.     public function __construct()
  53.     {
  54.         $this->lepCalculatorPobuts = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->name;
  63.     }
  64.     public function setName(string $name): self
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     public function getMaxCount(): ?int
  70.     {
  71.         return $this->maxCount;
  72.     }
  73.     public function setMaxCount(int $maxCount): self
  74.     {
  75.         $this->maxCount $maxCount;
  76.         return $this;
  77.     }
  78.     public function getWatt(): ?int
  79.     {
  80.         return $this->watt;
  81.     }
  82.     public function setWatt(?int $watt): self
  83.     {
  84.         $this->watt $watt;
  85.         return $this;
  86.     }
  87.     public function getHour(): ?int
  88.     {
  89.         return $this->hour;
  90.     }
  91.     public function setHour(?int $hour): self
  92.     {
  93.         $this->hour $hour;
  94.         return $this;
  95.     }
  96.     public function getOrders(): ?int
  97.     {
  98.         return $this->orders;
  99.     }
  100.     public function setOrders(?int $orders): self
  101.     {
  102.         $this->orders $orders;
  103.         return $this;
  104.     }
  105.     public function getParent(): ?self
  106.     {
  107.         return $this->parent;
  108.     }
  109.     public function setParent(?self $parent): self
  110.     {
  111.         $this->parent $parent;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, self>
  116.      */
  117.     public function getLepCalculatorPobuts(): Collection
  118.     {
  119.         return $this->lepCalculatorPobuts;
  120.     }
  121.     public function addLepCalculatorPobut(self $lepCalculatorPobut): self
  122.     {
  123.         if (!$this->lepCalculatorPobuts->contains($lepCalculatorPobut)) {
  124.             $this->lepCalculatorPobuts->add($lepCalculatorPobut);
  125.             $lepCalculatorPobut->setParent($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeLepCalculatorPobut(self $lepCalculatorPobut): self
  130.     {
  131.         if ($this->lepCalculatorPobuts->removeElement($lepCalculatorPobut)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($lepCalculatorPobut->getParent() === $this) {
  134.                 $lepCalculatorPobut->setParent(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139. }