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