src/Entity/PwOtg.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\PwOtgRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use ApiPlatform\Metadata\ApiFilter;
  10. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Metadata\ApiProperty;
  12. #[ORM\Entity(repositoryClassPwOtgRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['PwOtg:read']],
  15.     denormalizationContext: ['groups' => ['PwOtg:write']],
  16. )]
  17. #[ApiFilter(SearchFilter::class, properties: ['name' => 'ipartial''code' => 'exact'])]
  18. class PwOtg
  19. {
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  22.     #[ORM\Column]
  23.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read'])]
  24.     private ?int $id null;
  25.     #[ORM\Column(length255uniquetrue)]
  26.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read'])]
  27.     private ?string $code null;
  28.     #[ORM\Column(length255)]
  29.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read'])]
  30.     private ?string $name null;
  31.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwCity::class)]
  32.     private Collection $pwCities;
  33.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwAccident::class)]
  34.     private Collection $pwAccidents;
  35.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwAccount::class)]
  36.     private Collection $accounts;
  37.     public function __construct()
  38.     {
  39.         $this->pwCities = new ArrayCollection();
  40.         $this->pwAccidents = new ArrayCollection();
  41.         $this->accounts = new ArrayCollection();
  42.     }
  43.     public function getId(): ?int
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getCode(): ?string
  48.     {
  49.         return $this->code;
  50.     }
  51.     public function setCode(?string $code): static
  52.     {
  53.         $this->code $code;
  54.         return $this;
  55.     }
  56.     public function getName(): ?string
  57.     {
  58.         return $this->name;
  59.     }
  60.     public function setName(string $name): static
  61.     {
  62.         $this->name $name;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return Collection<int, PwCity>
  67.      */
  68.     public function getPwCities(): Collection
  69.     {
  70.         return $this->pwCities;
  71.     }
  72.     public function addPwCity(PwCity $pwCity): static
  73.     {
  74.         if (!$this->pwCities->contains($pwCity)) {
  75.             $this->pwCities->add($pwCity);
  76.             $pwCity->setOtg($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removePwCity(PwCity $pwCity): static
  81.     {
  82.         if ($this->pwCities->removeElement($pwCity)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($pwCity->getOtg() === $this) {
  85.                 $pwCity->setOtg(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection<int, PwAccident>
  92.      */
  93.     public function getPwAccidents(): Collection
  94.     {
  95.         return $this->pwAccidents;
  96.     }
  97.     public function addPwAccident(PwAccident $pwAccident): static
  98.     {
  99.         if (!$this->pwAccidents->contains($pwAccident)) {
  100.             $this->pwAccidents->add($pwAccident);
  101.             $pwAccident->setOtg($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removePwAccident(PwAccident $pwAccident): static
  106.     {
  107.         if ($this->pwAccidents->removeElement($pwAccident)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($pwAccident->getOtg() === $this) {
  110.                 $pwAccident->setOtg(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection<int, PwAccount>
  117.      */
  118.     public function getAccounts(): Collection
  119.     {
  120.         return $this->accounts;
  121.     }
  122.     public function addAccount(PwAccount $account): static
  123.     {
  124.         if (!$this->accounts->contains($account)) {
  125.             $this->accounts->add($account);
  126.             $account->setOtg($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeAccount(PwAccount $account): static
  131.     {
  132.         if ($this->accounts->removeElement($account)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($account->getOtg() === $this) {
  135.                 $account->setOtg(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140. }