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''PwAddressQ:read'])]
  29.     private ?int $id null;
  30.     #[ORM\Column(length255uniquetrue)]
  31.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read''PwAddressQ:read'])]
  32.     private ?string $code null;
  33.     #[ORM\Column(length255)]
  34.     #[Groups(['PwAccident:read''PwAccident:write''PwOtg:read''PwCity:read''PwAddressQ: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.     #[ORM\OneToMany(mappedBy'otg'targetEntityPwAddressQueue::class)]
  43.     private Collection $pwAddressQueues;
  44.     public function __construct()
  45.     {
  46.         $this->pwCities = new ArrayCollection();
  47.         $this->pwAccidents = new ArrayCollection();
  48.         $this->accounts = new ArrayCollection();
  49.         $this->pwAddressQueues = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getCode(): ?string
  56.     {
  57.         return $this->code;
  58.     }
  59.     public function setCode(?string $code): static
  60.     {
  61.         $this->code $code;
  62.         return $this;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(string $name): static
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, PwCity>
  75.      */
  76.     public function getPwCities(): Collection
  77.     {
  78.         return $this->pwCities;
  79.     }
  80.     public function addPwCity(PwCity $pwCity): static
  81.     {
  82.         if (!$this->pwCities->contains($pwCity)) {
  83.             $this->pwCities->add($pwCity);
  84.             $pwCity->setOtg($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removePwCity(PwCity $pwCity): static
  89.     {
  90.         if ($this->pwCities->removeElement($pwCity)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($pwCity->getOtg() === $this) {
  93.                 $pwCity->setOtg(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, PwAccident>
  100.      */
  101.     public function getPwAccidents(): Collection
  102.     {
  103.         return $this->pwAccidents;
  104.     }
  105.     public function addPwAccident(PwAccident $pwAccident): static
  106.     {
  107.         if (!$this->pwAccidents->contains($pwAccident)) {
  108.             $this->pwAccidents->add($pwAccident);
  109.             $pwAccident->setOtg($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removePwAccident(PwAccident $pwAccident): static
  114.     {
  115.         if ($this->pwAccidents->removeElement($pwAccident)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($pwAccident->getOtg() === $this) {
  118.                 $pwAccident->setOtg(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection<int, PwAccount>
  125.      */
  126.     public function getAccounts(): Collection
  127.     {
  128.         return $this->accounts;
  129.     }
  130.     public function addAccount(PwAccount $account): static
  131.     {
  132.         if (!$this->accounts->contains($account)) {
  133.             $this->accounts->add($account);
  134.             $account->setOtg($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeAccount(PwAccount $account): static
  139.     {
  140.         if ($this->accounts->removeElement($account)) {
  141.             // set the owning side to null (unless already changed)
  142.             if ($account->getOtg() === $this) {
  143.                 $account->setOtg(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148.     /**
  149.      * @return Collection<int, PwAddressQueue>
  150.      */
  151.     public function getPwAddressQueues(): Collection
  152.     {
  153.         return $this->pwAddressQueues;
  154.     }
  155.     public function addPwAddressQueue(PwAddressQueue $pwAddressQueue): static
  156.     {
  157.         if (!$this->pwAddressQueues->contains($pwAddressQueue)) {
  158.             $this->pwAddressQueues->add($pwAddressQueue);
  159.             $pwAddressQueue->setOtg($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function removePwAddressQueue(PwAddressQueue $pwAddressQueue): static
  164.     {
  165.         if ($this->pwAddressQueues->removeElement($pwAddressQueue)) {
  166.             // set the owning side to null (unless already changed)
  167.             if ($pwAddressQueue->getOtg() === $this) {
  168.                 $pwAddressQueue->setOtg(null);
  169.             }
  170.         }
  171.         return $this;
  172.     }
  173. }