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.     public function __construct()
  42.     {
  43.         $this->pwAccidents = new ArrayCollection();
  44.         $this->accounts = new ArrayCollection();
  45.         $this->pwAddressQueues = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getCity(): ?PwCity
  52.     {
  53.         return $this->city;
  54.     }
  55.     public function setCity(?PwCity $city): static
  56.     {
  57.         $this->city $city;
  58.         return $this;
  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.     /**
  70.      * @return Collection<int, PwAccident>
  71.      */
  72.     public function getPwAccidents(): Collection
  73.     {
  74.         return $this->pwAccidents;
  75.     }
  76.     public function addPwAccident(PwAccident $pwAccident): static
  77.     {
  78.         if (!$this->pwAccidents->contains($pwAccident)) {
  79.             $this->pwAccidents->add($pwAccident);
  80.             $pwAccident->setStreet($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removePwAccident(PwAccident $pwAccident): static
  85.     {
  86.         if ($this->pwAccidents->removeElement($pwAccident)) {
  87.             // set the owning side to null (unless already changed)
  88.             if ($pwAccident->getStreet() === $this) {
  89.                 $pwAccident->setStreet(null);
  90.             }
  91.         }
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return Collection<int, PwAccount>
  96.      */
  97.     public function getAccounts(): Collection
  98.     {
  99.         return $this->accounts;
  100.     }
  101.     public function addAccount(PwAccount $account): static
  102.     {
  103.         if (!$this->accounts->contains($account)) {
  104.             $this->accounts->add($account);
  105.             $account->setStreet($this);
  106.         }
  107.         return $this;
  108.     }
  109.     public function removeAccount(PwAccount $account): static
  110.     {
  111.         if ($this->accounts->removeElement($account)) {
  112.             // set the owning side to null (unless already changed)
  113.             if ($account->getStreet() === $this) {
  114.                 $account->setStreet(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }
  119.     /**
  120.      * @return Collection<int, PwAddressQueue>
  121.      */
  122.     public function getPwAddressQueues(): Collection
  123.     {
  124.         return $this->pwAddressQueues;
  125.     }
  126.     public function addPwAddressQueue(PwAddressQueue $pwAddressQueue): static
  127.     {
  128.         if (!$this->pwAddressQueues->contains($pwAddressQueue)) {
  129.             $this->pwAddressQueues->add($pwAddressQueue);
  130.             $pwAddressQueue->setStreet($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removePwAddressQueue(PwAddressQueue $pwAddressQueue): static
  135.     {
  136.         if ($this->pwAddressQueues->removeElement($pwAddressQueue)) {
  137.             // set the owning side to null (unless already changed)
  138.             if ($pwAddressQueue->getStreet() === $this) {
  139.                 $pwAddressQueue->setStreet(null);
  140.             }
  141.         }
  142.         return $this;
  143.     }
  144. }