src/Entity/PwCity.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\PwCityRepository;
  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. #[ORM\Entity(repositoryClassPwCityRepository::class)]
  12. #[ApiResource(
  13.     normalizationContext: ['groups' => ['PwCity:read']],
  14.     denormalizationContext: ['groups' => ['PwCity:write']],
  15.     cacheHeaders: [
  16.         'max_age' => 3600
  17.         'shared_max_age' => 7200
  18.         'vary' => ['Authorization''Accept-Language']
  19.     ],
  20. )]
  21. #[ApiFilter(SearchFilter::class, properties: ['name' => 'ipartial''otg.id' => 'exact''codeOtg' => 'exact'])]
  22. class PwCity
  23. {
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  26.     #[ORM\Column]
  27.     #[Groups(['PwAccident:read''PwAccident:write''PwCity:read''PwAddressQ:read'])]
  28.     private ?int $id null;
  29.     #[Groups(['PwAccident:read''PwAccident:write''PwCity:read''PwAddressQ:read'])]
  30.     #[ORM\Column(length255nullabletrue)]
  31.     private ?string $name null;
  32.     #[Groups(['PwAccident:read''PwAccident:write''PwCity:read''PwAddressQ:read'])]
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $codeOtg null;
  35.     #[ORM\OneToMany(mappedBy'city'targetEntityPwStreet::class)]
  36.     private Collection $pwStreets;
  37.     #[ORM\OneToMany(mappedBy'city'targetEntityPwAccident::class)]
  38.     private Collection $pwAccidents;
  39.     #[Groups(['PwCity:read'])]
  40.     #[ORM\ManyToOne(inversedBy'pwCities')]
  41.     private ?PwOtg $otg null;
  42.     #[ORM\OneToMany(mappedBy'city'targetEntityPwAccount::class)]
  43.     private Collection $accounts;
  44.     #[ORM\OneToMany(mappedBy'city'targetEntityPwAddressQueue::class)]
  45.     private Collection $pwAddressQueues;
  46.     #[ORM\OneToMany(mappedBy'city'targetEntityPwAccidentPlanedHistory::class)]
  47.     private Collection $pwAccidentPlanedHistories;
  48.     public function __construct()
  49.     {
  50.         $this->pwStreets = new ArrayCollection();
  51.         $this->pwAccidents = new ArrayCollection();
  52.         $this->accounts = new ArrayCollection();
  53.         $this->pwAddressQueues = new ArrayCollection();
  54.         $this->pwAccidentPlanedHistories = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->name;
  63.     }
  64.     public function setName(?string $name): static
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     public function getCodeOtg(): ?string
  70.     {
  71.         return $this->codeOtg;
  72.     }
  73.     public function setCodeOtg(?string $codeOtg): static
  74.     {
  75.         $this->codeOtg $codeOtg;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection<int, PwStreet>
  80.      */
  81.     public function getPwStreets(): Collection
  82.     {
  83.         return $this->pwStreets;
  84.     }
  85.     public function addPwStreet(PwStreet $pwStreet): static
  86.     {
  87.         if (!$this->pwStreets->contains($pwStreet)) {
  88.             $this->pwStreets->add($pwStreet);
  89.             $pwStreet->setCity($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removePwStreet(PwStreet $pwStreet): static
  94.     {
  95.         if ($this->pwStreets->removeElement($pwStreet)) {
  96.             // set the owning side to null (unless already changed)
  97.             if ($pwStreet->getCity() === $this) {
  98.                 $pwStreet->setCity(null);
  99.             }
  100.         }
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, PwAccident>
  105.      */
  106.     public function getPwAccidents(): Collection
  107.     {
  108.         return $this->pwAccidents;
  109.     }
  110.     public function addPwAccident(PwAccident $pwAccident): static
  111.     {
  112.         if (!$this->pwAccidents->contains($pwAccident)) {
  113.             $this->pwAccidents->add($pwAccident);
  114.             $pwAccident->setCity($this);
  115.         }
  116.         return $this;
  117.     }
  118.     public function removePwAccident(PwAccident $pwAccident): static
  119.     {
  120.         if ($this->pwAccidents->removeElement($pwAccident)) {
  121.             // set the owning side to null (unless already changed)
  122.             if ($pwAccident->getCity() === $this) {
  123.                 $pwAccident->setCity(null);
  124.             }
  125.         }
  126.         return $this;
  127.     }
  128.     public function getOtg(): ?PwOtg
  129.     {
  130.         return $this->otg;
  131.     }
  132.     public function setOtg(?PwOtg $otg): static
  133.     {
  134.         $this->otg $otg;
  135.         return $this;
  136.     }
  137.     /**
  138.      * @return Collection<int, PwAccount>
  139.      */
  140.     public function getAccounts(): Collection
  141.     {
  142.         return $this->accounts;
  143.     }
  144.     public function addAccount(PwAccount $account): static
  145.     {
  146.         if (!$this->accounts->contains($account)) {
  147.             $this->accounts->add($account);
  148.             $account->setCity($this);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeAccount(PwAccount $account): static
  153.     {
  154.         if ($this->accounts->removeElement($account)) {
  155.             // set the owning side to null (unless already changed)
  156.             if ($account->getCity() === $this) {
  157.                 $account->setCity(null);
  158.             }
  159.         }
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return Collection<int, PwAddressQueue>
  164.      */
  165.     public function getPwAddressQueues(): Collection
  166.     {
  167.         return $this->pwAddressQueues;
  168.     }
  169.     public function addPwAddressQueue(PwAddressQueue $pwAddressQueue): static
  170.     {
  171.         if (!$this->pwAddressQueues->contains($pwAddressQueue)) {
  172.             $this->pwAddressQueues->add($pwAddressQueue);
  173.             $pwAddressQueue->setCity($this);
  174.         }
  175.         return $this;
  176.     }
  177.     public function removePwAddressQueue(PwAddressQueue $pwAddressQueue): static
  178.     {
  179.         if ($this->pwAddressQueues->removeElement($pwAddressQueue)) {
  180.             // set the owning side to null (unless already changed)
  181.             if ($pwAddressQueue->getCity() === $this) {
  182.                 $pwAddressQueue->setCity(null);
  183.             }
  184.         }
  185.         return $this;
  186.     }
  187.     /**
  188.      * @return Collection<int, PwAccidentPlanedHistory>
  189.      */
  190.     public function getPwAccidentPlanedHistories(): Collection
  191.     {
  192.         return $this->pwAccidentPlanedHistories;
  193.     }
  194.     public function addPwAccidentPlanedHistory(PwAccidentPlanedHistory $pwAccidentPlanedHistory): static
  195.     {
  196.         if (!$this->pwAccidentPlanedHistories->contains($pwAccidentPlanedHistory)) {
  197.             $this->pwAccidentPlanedHistories->add($pwAccidentPlanedHistory);
  198.             $pwAccidentPlanedHistory->setCity($this);
  199.         }
  200.         return $this;
  201.     }
  202.     public function removePwAccidentPlanedHistory(PwAccidentPlanedHistory $pwAccidentPlanedHistory): static
  203.     {
  204.         if ($this->pwAccidentPlanedHistories->removeElement($pwAccidentPlanedHistory)) {
  205.             // set the owning side to null (unless already changed)
  206.             if ($pwAccidentPlanedHistory->getCity() === $this) {
  207.                 $pwAccidentPlanedHistory->setCity(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212. }