src/Entity/PwStreet.php line 26

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