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.     public function __construct()
  47.     {
  48.         $this->pwStreets = new ArrayCollection();
  49.         $this->pwAccidents = new ArrayCollection();
  50.         $this->accounts = new ArrayCollection();
  51.         $this->pwAddressQueues = new ArrayCollection();
  52.     }
  53.     public function getId(): ?int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(?string $name): static
  62.     {
  63.         $this->name $name;
  64.         return $this;
  65.     }
  66.     public function getCodeOtg(): ?string
  67.     {
  68.         return $this->codeOtg;
  69.     }
  70.     public function setCodeOtg(?string $codeOtg): static
  71.     {
  72.         $this->codeOtg $codeOtg;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return Collection<int, PwStreet>
  77.      */
  78.     public function getPwStreets(): Collection
  79.     {
  80.         return $this->pwStreets;
  81.     }
  82.     public function addPwStreet(PwStreet $pwStreet): static
  83.     {
  84.         if (!$this->pwStreets->contains($pwStreet)) {
  85.             $this->pwStreets->add($pwStreet);
  86.             $pwStreet->setCity($this);
  87.         }
  88.         return $this;
  89.     }
  90.     public function removePwStreet(PwStreet $pwStreet): static
  91.     {
  92.         if ($this->pwStreets->removeElement($pwStreet)) {
  93.             // set the owning side to null (unless already changed)
  94.             if ($pwStreet->getCity() === $this) {
  95.                 $pwStreet->setCity(null);
  96.             }
  97.         }
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, PwAccident>
  102.      */
  103.     public function getPwAccidents(): Collection
  104.     {
  105.         return $this->pwAccidents;
  106.     }
  107.     public function addPwAccident(PwAccident $pwAccident): static
  108.     {
  109.         if (!$this->pwAccidents->contains($pwAccident)) {
  110.             $this->pwAccidents->add($pwAccident);
  111.             $pwAccident->setCity($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removePwAccident(PwAccident $pwAccident): static
  116.     {
  117.         if ($this->pwAccidents->removeElement($pwAccident)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($pwAccident->getCity() === $this) {
  120.                 $pwAccident->setCity(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     public function getOtg(): ?PwOtg
  126.     {
  127.         return $this->otg;
  128.     }
  129.     public function setOtg(?PwOtg $otg): static
  130.     {
  131.         $this->otg $otg;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return Collection<int, PwAccount>
  136.      */
  137.     public function getAccounts(): Collection
  138.     {
  139.         return $this->accounts;
  140.     }
  141.     public function addAccount(PwAccount $account): static
  142.     {
  143.         if (!$this->accounts->contains($account)) {
  144.             $this->accounts->add($account);
  145.             $account->setCity($this);
  146.         }
  147.         return $this;
  148.     }
  149.     public function removeAccount(PwAccount $account): static
  150.     {
  151.         if ($this->accounts->removeElement($account)) {
  152.             // set the owning side to null (unless already changed)
  153.             if ($account->getCity() === $this) {
  154.                 $account->setCity(null);
  155.             }
  156.         }
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection<int, PwAddressQueue>
  161.      */
  162.     public function getPwAddressQueues(): Collection
  163.     {
  164.         return $this->pwAddressQueues;
  165.     }
  166.     public function addPwAddressQueue(PwAddressQueue $pwAddressQueue): static
  167.     {
  168.         if (!$this->pwAddressQueues->contains($pwAddressQueue)) {
  169.             $this->pwAddressQueues->add($pwAddressQueue);
  170.             $pwAddressQueue->setCity($this);
  171.         }
  172.         return $this;
  173.     }
  174.     public function removePwAddressQueue(PwAddressQueue $pwAddressQueue): static
  175.     {
  176.         if ($this->pwAddressQueues->removeElement($pwAddressQueue)) {
  177.             // set the owning side to null (unless already changed)
  178.             if ($pwAddressQueue->getCity() === $this) {
  179.                 $pwAddressQueue->setCity(null);
  180.             }
  181.         }
  182.         return $this;
  183.     }
  184. }