src/Entity/OperRozp.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\OperRozpRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use ApiPlatform\Metadata\Post;
  9. use ApiPlatform\Metadata\Get;
  10. use ApiPlatform\Metadata\Delete;
  11. use ApiPlatform\Metadata\Put;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ORM\Entity(repositoryClassOperRozpRepository::class)]
  14. #[Get]
  15. #[Get]
  16. #[Put(security"is_granted('ROLE_ADMIN')")]
  17. #[Post(security"is_granted('ROLE_ADMIN')")]
  18. #[Delete(security"is_granted('ROLE_ADMIN')")]
  19. #[ApiResource(
  20.     normalizationContext: ['groups' => ['read']],
  21.     denormalizationContext: ['groups' => ['write']],
  22.     order: ['id' => 'DESC']
  23. )]
  24. class OperRozp
  25. {
  26.     #[ORM\Id]
  27.     #[ORM\GeneratedValue]
  28.     #[ORM\Column]
  29.     #[Groups(['read''write'])]
  30.     private ?int $id null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     #[Groups(['read''write'])]
  33.     private ?string $name null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?int $orders null;
  36.     #[ORM\Column(nullabletrue)]
  37.     private ?int $active null;
  38.     #[ORM\OneToMany(mappedBy'oper'targetEntityCalculatorPriceYur::class)]
  39.     private Collection $calculatorPriceYurs;
  40.     public function __construct()
  41.     {
  42.         $this->calculatorPriceYurs = new ArrayCollection();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(?string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getOrders(): ?int
  58.     {
  59.         return $this->orders;
  60.     }
  61.     public function setOrders(?int $orders): self
  62.     {
  63.         $this->orders $orders;
  64.         return $this;
  65.     }
  66.     public function getActive(): ?int
  67.     {
  68.         return $this->active;
  69.     }
  70.     public function setActive(?int $active): self
  71.     {
  72.         $this->active $active;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return Collection<int, CalculatorPriceYur>
  77.      */
  78.     public function getCalculatorPriceYurs(): Collection
  79.     {
  80.         return $this->calculatorPriceYurs;
  81.     }
  82.     public function addCalculatorPriceYur(CalculatorPriceYur $calculatorPriceYur): self
  83.     {
  84.         if (!$this->calculatorPriceYurs->contains($calculatorPriceYur)) {
  85.             $this->calculatorPriceYurs->add($calculatorPriceYur);
  86.             $calculatorPriceYur->setOper($this);
  87.         }
  88.         return $this;
  89.     }
  90.     public function removeCalculatorPriceYur(CalculatorPriceYur $calculatorPriceYur): self
  91.     {
  92.         if ($this->calculatorPriceYurs->removeElement($calculatorPriceYur)) {
  93.             // set the owning side to null (unless already changed)
  94.             if ($calculatorPriceYur->getOper() === $this) {
  95.                 $calculatorPriceYur->setOper(null);
  96.             }
  97.         }
  98.         return $this;
  99.     }
  100. }