src/Entity/PwOtg.php line 28

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.     cacheHeaders: [
  17.         'max_age' => 3600
  18.         'shared_max_age' => 7200
  19.         'vary' => ['Authorization''Accept-Language']
  20.     ],
  21. )]
  22. #[ApiFilter(SearchFilter::class, properties: ['name' => 'ipartial''code' => 'exact'])]
  23. class PwOtg
  24. {
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  27.     #[ORM\Column]
  28.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read'])]
  29.     private ?int $id null;
  30.     #[ORM\Column(length255uniquetrue)]
  31.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read'])]
  32.     private ?string $code null;
  33.     #[ORM\Column(length255)]
  34.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read''PwCity:read'])]
  35.     private ?string $name null;
  36.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwCity::class)]
  37.     private Collection $pwCities;
  38.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwAccident::class)]
  39.     private Collection $pwAccidents;
  40.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwAccount::class)]
  41.     private Collection $accounts;
  42.     public function __construct()
  43.     {
  44.         $this->pwCities = new ArrayCollection();
  45.         $this->pwAccidents = new ArrayCollection();
  46.         $this->accounts = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getCode(): ?string
  53.     {
  54.         return $this->code;
  55.     }
  56.     public function setCode(?string $code): static
  57.     {
  58.         $this->code $code;
  59.         return $this;
  60.     }
  61.     public function getName(): ?string
  62.     {
  63.         return $this->name;
  64.     }
  65.     public function setName(string $name): static
  66.     {
  67.         $this->name $name;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection<int, PwCity>
  72.      */
  73.     public function getPwCities(): Collection
  74.     {
  75.         return $this->pwCities;
  76.     }
  77.     public function addPwCity(PwCity $pwCity): static
  78.     {
  79.         if (!$this->pwCities->contains($pwCity)) {
  80.             $this->pwCities->add($pwCity);
  81.             $pwCity->setOtg($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removePwCity(PwCity $pwCity): static
  86.     {
  87.         if ($this->pwCities->removeElement($pwCity)) {
  88.             // set the owning side to null (unless already changed)
  89.             if ($pwCity->getOtg() === $this) {
  90.                 $pwCity->setOtg(null);
  91.             }
  92.         }
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return Collection<int, PwAccident>
  97.      */
  98.     public function getPwAccidents(): Collection
  99.     {
  100.         return $this->pwAccidents;
  101.     }
  102.     public function addPwAccident(PwAccident $pwAccident): static
  103.     {
  104.         if (!$this->pwAccidents->contains($pwAccident)) {
  105.             $this->pwAccidents->add($pwAccident);
  106.             $pwAccident->setOtg($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removePwAccident(PwAccident $pwAccident): static
  111.     {
  112.         if ($this->pwAccidents->removeElement($pwAccident)) {
  113.             // set the owning side to null (unless already changed)
  114.             if ($pwAccident->getOtg() === $this) {
  115.                 $pwAccident->setOtg(null);
  116.             }
  117.         }
  118.         return $this;
  119.     }
  120.     /**
  121.      * @return Collection<int, PwAccount>
  122.      */
  123.     public function getAccounts(): Collection
  124.     {
  125.         return $this->accounts;
  126.     }
  127.     public function addAccount(PwAccount $account): static
  128.     {
  129.         if (!$this->accounts->contains($account)) {
  130.             $this->accounts->add($account);
  131.             $account->setOtg($this);
  132.         }
  133.         return $this;
  134.     }
  135.     public function removeAccount(PwAccount $account): static
  136.     {
  137.         if ($this->accounts->removeElement($account)) {
  138.             // set the owning side to null (unless already changed)
  139.             if ($account->getOtg() === $this) {
  140.                 $account->setOtg(null);
  141.             }
  142.         }
  143.         return $this;
  144.     }
  145. }